Closed davidel27 closed 3 years ago
The specified module could not be found.
This error could mean that PythonSlave.dll
itself is missing some dependency. The first thing I would check is whether or not Python is on PATH. PythonFMU requires Python3 on the system (and added to PATH).
You can also use Dependeny Walker to see what dlls the FMU requires (plain PythonFMU requires Python3.dll only)
Hi thank you for your fast replay. You were right, python was not added to my path. I use anaconda thefore I added to path the following directorys: ../Anaconda3 ../Anaconda3/Scripts In the first directory there is python.exe and python3.dll. I managed to launch python and build the fmu directly through the cmd. (i.e. python pythonfmu build -f) Now it is no longer shows the initial error but just kills the MATLAB and simulink with no reason given.
How about other importing tools? It is quick to check with FMPy using python -m fmpy.gui
It is still not working.
I opened a new folder in C:\test and created python file with the name FMUtest.py:
Later I opened the CMD as an admini: and wrote the following commands:
And the FMU file were created:
Using FMPy the following error occures:
Same error for the FMPy GUI when trying to load the FMU.
Using MATLAB simulink, it does recognise the FMU and the outputs:
but when trying to run simulation, it crashes with the following error:
I also tried to use RecurDyn as master but it also crushed without giving an error.
Can you share the FMU you have?
You are using Python 64 bit right?
Yes I have python 64 and the FMU file:
I'm running Python 3.7. So I guess the Python 3.9 API have some new functions. Nevertheless, the FMU loads and provides an error. Could it be your Python version? Perhaps Python 3.9 is just incompatible with PythonFMU. I think 3.8 is the highest we have tested.
I use python 3.8.3
I will try python 3.7 and let you know. thank you very much!
Seems Python 3.9 is also ok: https://github.com/NTNU-IHB/PythonFMU/pull/111
Can you give me the environment that you use? Is there additional stuff I need to install except python, PythonFMU? (with no external packges)
I'm using plain Python 3.7.4. pip install pythonfmu
is enough if you only use core Python libraries.
However, the CI is running with versions ranging from 3.6 to 3.8.
Btw, I looked at the time API and there is no function called pause
. So that would lead to a crash. Also, perhaps MATLAB/Simulink do not like the needsExecutionTool=true
attribute in the modelDescription.xml
? Try re-exporting with --no-external-tool
Also the error you get from fmpy does not seem to be related to PythonFMU (etree). Does it work with other FMUs?
I created a new environment in anaconda named py374 and have a python version 3.7.4. I installed the libraries: pythonfmu FMPy
I changed a little bit the code:
and build using the command: pythonfmu build -f FMUtest.py --no-external-tool
Using FMPy GUI it succeed!!:
But Using MATLAB simulink it resulted with the same error as before:
I will try to contact MathWork support to obtain the solution.
The files in the folder: FMUtest.zip
Best regards and Thank you very much!!
Closing. Please re-open if you find that PythonFMU has an issue that keeps it from working with MATLAB/Simulink.
I had the same problem, did you solve it?
I had the same problem, did you solve it?
Yes I have managed to solve it.
Can you explicitly say which software you used as master? And which python environment do you have? (is it anaconda?) And also the operating system. The solution may be a little bit diffrent in each scenario.
I had the same problem, did you solve it?
Yes I have managed to solve it.
Can you explicitly say which software you used as master? And which python environment do you have? (is it anaconda?) And also the operating system. The solution may be a little bit diffrent in each scenario.
I'm using Anaconda environment(D:\Anaconda3\envs\fmi_env)
on win11 to execute pythonfmu build -f
.I added (D:\Anaconda3\envs\fmi_env)
to the system path. Everything works fine in FMPy GUI, on the same machine, import to simulink (matlab 2020R)
without scope
connected, click to run without crashing, connect to scope
to run and it crashes.
I had the same problem, did you solve it?
Yes I have managed to solve it. Can you explicitly say which software you used as master? And which python environment do you have? (is it anaconda?) And also the operating system. The solution may be a little bit diffrent in each scenario.
I'm using Anaconda environment
(D:\Anaconda3\envs\fmi_env)
on win11 to executepythonfmu build -f
.I added(D:\Anaconda3\envs\fmi_env)
to the system path. Everything works fine in FMPy GUI, on the same machine, import to simulink(matlab 2020R)
withoutscope
connected, click to run without crashing, connect toscope
to run and it crashes.
The main issue is the usage of anaconda. In anaconda environment under windows, the environment variables are not properly defined. Although, manually adding the environment variables in the system PATH.
The solution that worked for me is to uninstall the anaconda framework and reinstall anaconda with "Add to PATH envirnment variables..." option checked (although it is not recomended by the anaconda installer).
Make sure to reboot your machine after reinstalling anaconda and that should work.
I had the same problem, did you solve it?
Yes I have managed to solve it. Can you explicitly say which software you used as master? And which python environment do you have? (is it anaconda?) And also the operating system. The solution may be a little bit diffrent in each scenario.
I'm using Anaconda environment
(D:\Anaconda3\envs\fmi_env)
on win11 to executepythonfmu build -f
.I added(D:\Anaconda3\envs\fmi_env)
to the system path. Everything works fine in FMPy GUI, on the same machine, import to simulink(matlab 2020R)
withoutscope
connected, click to run without crashing, connect toscope
to run and it crashes.The main issue is the usage of anaconda. In anaconda environment under windows, the environment variables are not properly defined. Although, manually adding the environment variables in the system PATH.
The solution that worked for me is to uninstall the anaconda framework and reinstall anaconda with "Add to PATH envirnment variables..." option checked (although it is not recomended by the anaconda installer).
Make sure to reboot your machine after reinstalling anaconda and that should work.
Thank you very much, now that it's working
Hello I have some issues with loading the fmu file that generated using PythonFMU to MATLAB simulink FMU import module. The model in matlab is the same model as the given example, just instead of using pyFMI I use matlab simulink. It recognises the model, the inputs and outputs of the FMU file, but when I try to simulate it, it results with the following error:
Error in supplied FMU: Unable to load dynamic library 'C:\Users\david\Documents\FMU\slrprj_fmu\c9a9319\PythonSlave\binaries\win64\PythonSlave.dll': The specified module could not be found. For more information, see the FMU troubleshooting documentation.
I checked for the following dll and it is do exist and it seems to be correct. Is there a way to fix that? Thank you and best regards