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.
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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi Daniel,
I can confirm there is some issues here!
To reproduce the issue on DWSIM 6.5.1
Create a sample simulation (a single stream of water with Raoult thermo)
Open Script Manager and add a simple script with text: print("Hello Daniel")
Set Python interpreter to Python.NET in Script Manager
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)
Run the script from Script Manager
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!
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:
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)
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:
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
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.
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.
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.
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
I believe that the correct path would be E:\winpython\python-3.8.10.amd64
unfortunately this is also don't work for me.
did you test running this python environment from somewhere else?
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.
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.
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.
Hi Daniel,
I can confirm there is some issues here!
To reproduce the issue on DWSIM 6.5.1
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!
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:
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
Sure!
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)
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:
I'll see what I can do to avoid this in the next DWSIM update.
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
3.9
Ah you are great Daniel!
A million thanks!
Best wishes
Fixed the issue, the next update will default Python.NET to Python 3.8. https://github.com/DanWBR/dwsim6/commit/bc0b6d1d54b1a1685977ca8e140e8441238d9b06
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!
yes, it will be enough.
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?