Menu

Tensorflow numpy pandas ....

2021-05-25
2021-05-30
1 2 3 > >> (Page 1 of 3)
  • Amir Nematollahi

    Hello;
    How can I use the libraries like TensorFlow, numpy, pandas, matplotlib and sklearn in python script in DWSIM like this article? : https://www.linkedin.com/pulse/integrating-chemical-process-simulator-tensorflow-daniel-medeiros/.
    when I just want to run the code in the article by Iron python, it don't recognize these libraries. How I can install these libraries in Iron python?
    I also downloaded the files associated with Neural Network Unit Operation for DWSIM Simulator (64-bit Windows) and copied those file into unitops directory and tried to use python.NET to run the code but I encountered this Error:
    Error UO-02: Unable to load DLL 'python38': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
    my python bridge settings ( python Binaries path) in my PC is : E:\DWSIM6\pythonnet\3.8
    In addition, I copied the python.Runtime.dll for python 3.8 over the existing one in the main folder but I encountered the same Error.

     
  • Daniel Medeiros

    Daniel Medeiros - 2021-05-25

    You're confusing everything. DWSIM has two Python interpreters: IronPython and Python.NET. IronPython is embedded in DWSIM and doesn't need any external libraries, but doesn't support any additional modules except for the ones in the Python standard library. Python.NET runs python code using an external installation through a "bridge".

    The Neural Network Unit Operation uses IronPython. It is totatlly different from my article in LinkedIn where I've ran Tensorflow with Python.NET. The NNUO was designed to be standalone. If you want to run the code in my article then you must have a python installation elsewhere with all these modules installed, then set the Python path to your installation and select "Python.NET" as the interpreter.

     
  • Amir Nematollahi

    Thanks so much sir, I really appreciate your help.
    I feel so sorry,I'm just new to coding and DWSIM environment and didn't have any idea about the differences between interpreters.

     
    • Amir Nematollahi

      As I saw in other conversations, you suggested to use winpython for a python source .I will implement winpython 3.8 library packages through python.NET to run the code in your article. so I hope will work.

       
  • Amir Nematollahi

    I just addressed winpython 3.8 packages to the python Binaries path in DWSIM and tried to run the codes, but unfortunately I got the same Error as before:
    Unable to load DLL 'python38': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
    python Binaries path : E:\winpython\python-3.8.10.amd64\Lib\site-packages
    Python.Runtime.dll and python38.dll are in the path above.
    I also tried to address my conda environments to run the code but didn't work.
    I follow below to try but no luck.
    https://github.com/pythonnet/pythonnet/wiki/using-python.net-with-virtual-environments

     
  • Daniel Medeiros

    Daniel Medeiros - 2021-05-26

    I believe that the correct path would be E:\winpython\python-3.8.10.amd64

     
  • Amir Nematollahi

    unfortunately this is also don't work for me.

     
  • Daniel Medeiros

    Daniel Medeiros - 2021-05-26

    did you test running this python environment from somewhere else?

     
    • Amir Nematollahi

      Yes, I set this path (E:\winpython\python-3.8.10.amd64) to pycharm and spyder which are the IDE's that I'm using for coding and could run the codes.
      Today I also create a new conda environment with all packages in need and set it to the DWSIM but still have the issue.

       
  • Daniel Medeiros

    Daniel Medeiros - 2021-05-26

    About Python.Runtime.dll: It is a DLL located in DWSIM's main installation directory. The version shipped by default supports Python 3.6. If you want to use DWSIM with Python 3.8, then you must replace Python.Runtime.dll in DWSIM's directory with the one located in the pythonnet/3.8 subdirectory.

    Why this happens? When you select Python.NET as the python interpreter, DWSIM calls some functions in Python.Runtime.dll which are hard-coded to a specific python native dll. For instance, the default Python.Runtime.dll will look for python36.dll.

    I know that this is a little confusing but I'm a failure trying to explain it better or make it clearer. Sorry.

     
  • Daniel Medeiros

    Daniel Medeiros - 2021-05-26

    IronPython, on the other hand, is self-contained. It runs all python commands in its own self-contained DLL. it doesn't need nor calls any python installation on your computer.

     
  • Mohammad

    Mohammad - 2021-05-27

    Hi Daniel,
    I can confirm there is some issues here!

    To reproduce the issue on DWSIM 6.5.1

    1. Create a sample simulation (a single stream of water with Raoult thermo)
    2. Open Script Manager and add a simple script with text: print("Hello Daniel")
    3. Set Python interpreter to Python.NET in Script Manager
    4. Set the Python Bridge Setting to a working Python 3.7 on Windows 10 (checked it works and there are binaries there I see python37.dll and python.exe there)
    5. Run the script from Script Manager
    6. I get the error unhandled error/exceptions (unable load DLL python37)

    NOTE:
    As you advised I also tried python38: change the bridge setting to working python 3.8, and copy the dll from the DWSIM pythonnet folder to the main DWSIM installation folder and I got the same error!

    NOTE 2
    The purpose is to use a working Python 3.7 or 3.8 with Numpy. Scipy and Tensoorflow for hybrid simulation!

     
  • Mohammad

    Mohammad - 2021-05-27

    Daniel,
    I followed your instruction here: https://sourceforge.net/p/dwsim/discussion/scripting/thread/7df261ad45/

    I am on Windows 10
    DWSIM 6.5.1 works fine
    DWSIM with Ironpython works fine
    The installed Python 3.7 is in D:\Python\Portable Python-3.7.7 x64\App\Python and I see python37.dll there ( I check the Python 3.7 with numpy and it works)
    I set the Python Bridge Setting in DWSIM to D:\Python\Portable Python-3.7.7 x64\App\Python where my python37.dll is there (standard python distribution is used)
    I set the Python Interpreter as Python.NET in Script Manager

    So everything looks fine, BUT DWSIM complains as below:

    System.AggregateException: One or more errors occurred. ---> System.DllNotFoundException: Unable to load DLL 'python37': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
       at Python.Runtime.Runtime.Py_IsInitialized()
       at Python.Runtime.Runtime.Initialize(Boolean initSigs) in C:\Users\Daniel\Source\Repos\pythonnet\src\runtime\runtime.cs:line 155
       at Python.Runtime.PythonEngine.Initialize(IEnumerable`1 args, Boolean setSysArgv, Boolean initSigs) in C:\Users\Daniel\Source\Repos\pythonnet\src\runtime\pythonengine.cs:line 176
       at Python.Runtime.Py.GIL() in C:\Users\Daniel\Source\Repos\pythonnet\src\runtime\pythonengine.cs:line 628
       at DWSIM.FormScript._Closure$__234-0._Lambda$__2() in C:\Users\Daniel\source\repos\DanWBR\dwsim6\DWSIM\Forms\FormScript.vb:line 286
    
     
  • Daniel Medeiros

    Daniel Medeiros - 2021-05-27

    I've compiled the latest version of Python.Runtime.dll for Py 3.6, 3.7 and 3.8, please give it a try.

     

    Last edit: Daniel Medeiros 2021-05-27
  • Mohammad

    Mohammad - 2021-05-27

    Sure!

     
  • Mohammad

    Mohammad - 2021-05-27

    The same error! The issue persists.

    I downloaded the pythonnet.zip from above poste
    Unzip and copy paste the Python.Runtime.dll to the DWSIM installation folder (overwrite the current file)

    System.AggregateException: One or more errors occurred. ---> System.DllNotFoundException: Unable to load DLL 'python37': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
    
     
  • Daniel Medeiros

    Daniel Medeiros - 2021-05-27

    I think I've found the reason. You need to add the same path to your PATH environment variable. In my computer, I was able to make it work by adding it as part of PATH in my user environment variables:

     
  • Daniel Medeiros

    Daniel Medeiros - 2021-05-27

    I'll see what I can do to avoid this in the next DWSIM update.

     
  • Mohammad

    Mohammad - 2021-05-27

    Hi Daniel,
    Many thanks for all your effort!

    I added the path, but now DWSIM closes when I click run script! I think you got the source of error!

    By the way the Setting in Python Bridge Setting seems does not honor by DWSIM if it requires to find the python from Windows Path variable!

    I am available for test and other help! Please let me know!

    NOTE I would appreciate to also add python 3.9 into DWSIM/pythonnet distribution!
    Right now it has 3.6, 3.7, and 3.8 and it

     
    • Daniel Medeiros

      Daniel Medeiros - 2021-05-27

      3.9

       
  • Mohammad

    Mohammad - 2021-05-27

    Ah you are great Daniel!

    A million thanks!

    Best wishes

     
  • Mohammad

    Mohammad - 2021-05-27

    I really appreciate it!
    Python 3.8 makes sense! as it is the most common these days!

    I hope setting the Python Bridge in DWSIM is enough and there was no requirement to set the environment path! That because they my have different python installed on their machine!

     
    • Daniel Medeiros

      Daniel Medeiros - 2021-05-27

      yes, it will be enough.

       
  • Mohamed Mazhar Laljee

    Hello, I just updated to the latest version from probably what was the August 2020 version. Can someone please tell me why does each step of the sensitivity analysis take much longer than before. Previously each step used to run under a second but now it takes 2-3. Is there something wrong?

     
1 2 3 > >> (Page 1 of 3)
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.