I have a problem concerning the import of packages like numpy and matplotlib.pyplot into Scripts in the newest version of DWSIM.
I already tried to reference the file location of python.exe at Global Settings>Miscelaneous>Python Settings>binaries path (I use Spyder in Anaconda).
Importing by appending the path to system does also not work for me.
importsyssys.path.append("C:Path...")
I even attempted to copy all available packages from Anaconda directly to C:\Users\user1\AppData\Local\DWSIM5\Lib
but all I got was an error while calling numpy.
ImportError:Importingthemultiarraynumpyextensionmodulefailed.Mostlikelyyouaretryingtoimportafailedbuildofnumpy.Ifyou're working with a numpy git repo, try `git clean -xdf` (removes allfilesnotunderversioncontrol).Otherwisereinstallnumpy.Originalerrorwas:cannotimportmultiarrayfromnumpy.core
Numpy works just fine in spider, so I don't see any fault with the version of numpy I run.
What is the correct way to import these packages?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
IronPython cannot import external packages other than the standard libraries included with DWSIM (lib folder). This is why I've included Python.NET as an alternative interpreter.
The compiled version of Python.NET included with DWSIM requires a Python 3.6 environment. To use it in DWSIM, you must set the Python path on General Settings to the folder where python36.dll is located.
While IronPython works like an internal python interpreter, exclusive for DWSIM, Python.NET integrates an external Python environment with DWSIM so you can use DWSIM objects (flowsheet, unit operations, streams, spreadsheet) and get/set their properties dynamically from memory as if you were running it on an external python editor.
would not be possible with IronPython, as there is no way to import TensorFlow libraries. In this case, TensorFlow, numpy, scipy and all dependencies are installed in an external Python 3.6 environment which is called by Python.NET and loaded in DWSIM each time the script is run.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I've taken a look at your article about simulating tensor flows and downloaded WinPython. It was very helpfull advice.
I then opened "Biodiesel Combustion (Cantera)", linked the path to python36.dll in global settings as you can see on the screenshot and ran the script to see if it works.
It gave me this error:
Combustion (Cantera): Unable to load DLL 'python36.dll': The specified module could not be
found. (Exception from HRESULT: 0x8007007E)
Do you have any idea why the program has problems accessing python36.dll?
It doesn't lead me very far when typed into the script editor, because the program searches python36.dll before accessing the script, so I still get the same old error.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello together,
i tried also to simulate the example which Daniel did for importing tensorflow.
But i have a very strange behaviour which i can´t explain myself.
I can run the Script in the Script Manager one time after i opened DWSIM. After that everytime i run the script the error "a bytes-like object is required, not str" appears. Does anybody had the same problem?
I have tried it with python version 3.8.0 and Python 3.9.4 and my DWSIM version is 8.0.4
Thanks in advance.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hey guys,
I have a problem concerning the import of packages like numpy and matplotlib.pyplot into Scripts in the newest version of DWSIM.
I already tried to reference the file location of python.exe at Global Settings>Miscelaneous>Python Settings>binaries path (I use Spyder in Anaconda).
Importing by appending the path to system does also not work for me.
I even attempted to copy all available packages from Anaconda directly to C:\Users\user1\AppData\Local\DWSIM5\Lib
but all I got was an error while calling numpy.
Numpy works just fine in spider, so I don't see any fault with the version of numpy I run.
What is the correct way to import these packages?
IronPython cannot import external packages other than the standard libraries included with DWSIM (lib folder). This is why I've included Python.NET as an alternative interpreter.
The compiled version of Python.NET included with DWSIM requires a Python 3.6 environment. To use it in DWSIM, you must set the Python path on General Settings to the folder where python36.dll is located.
I recommend installing a portable Python package like WinPython, specifically this one: https://sourceforge.net/projects/winpython/files/WinPython_3.6/3.6.5.0/WinPython64-3.6.5.0Qt5.exe/download
The syntax for .NET/DWSIM integration is a little bit different when compared to IronPtyhon. Check the Cantera sample and you'll spot the differences.
Regards
Daniel
While IronPython works like an internal python interpreter, exclusive for DWSIM, Python.NET integrates an external Python environment with DWSIM so you can use DWSIM objects (flowsheet, unit operations, streams, spreadsheet) and get/set their properties dynamically from memory as if you were running it on an external python editor.
More Python.NET info can be found at https://github.com/pythonnet/pythonnet
For instance, what I did in this article => https://www.linkedin.com/pulse/integrating-chemical-process-simulator-tensorflow-daniel-medeiros/
would not be possible with IronPython, as there is no way to import TensorFlow libraries. In this case, TensorFlow, numpy, scipy and all dependencies are installed in an external Python 3.6 environment which is called by Python.NET and loaded in DWSIM each time the script is run.
I've taken a look at your article about simulating tensor flows and downloaded WinPython. It was very helpfull advice.
I then opened "Biodiesel Combustion (Cantera)", linked the path to python36.dll in global settings as you can see on the screenshot and ran the script to see if it works.
It gave me this error:
Combustion (Cantera): Unable to load DLL 'python36.dll': The specified module could not be
found. (Exception from HRESULT: 0x8007007E)
Do you have any idea why the program has problems accessing python36.dll?
Check this: https://stackoverflow.com/a/25685000/1771296
Where should I insert
It doesn't lead me very far when typed into the script editor, because the program searches python36.dll before accessing the script, so I still get the same old error.
You must run this command from cmd.
You must determine the version of Visual C++ Redistributable required by python36.dll and install it accordingly.
https://stackoverflow.com/a/55948918/1771296
Hello together,
i tried also to simulate the example which Daniel did for importing tensorflow.
But i have a very strange behaviour which i can´t explain myself.
I can run the Script in the Script Manager one time after i opened DWSIM. After that everytime i run the script the error "a bytes-like object is required, not str" appears. Does anybody had the same problem?
I have tried it with python version 3.8.0 and Python 3.9.4 and my DWSIM version is 8.0.4
Thanks in advance.
I also have this error from time to time and I still can't figure out why it happens.