Reputation: 21
I'm on Ubuntu 20.04 trying to load and run an FMU exported from OpenModelica with PyFMI. When I run the code:
from pyfmi import load_fmu
model = load_fmu('Model.fmu')
The following error is produced:
File "src/pyfmi/fmi.pyx", line 7943, in pyfmi.fmi.load_fmu
File "src/pyfmi/fmi.pyx", line 7086, in pyfmi.fmi.FMUModelME2.__init__
File "src/pyfmi/fmi.pyx", line 3761, in pyfmi.fmi.FMUModelBase2.__init__
File "src/pyfmi/fmi.pyx", line 45, in pyfmi.fmi.encode
TypeError: latin_1_encode() argument 1 must be str, not bytes
The result is the same regardless of which I use the version of PyFMI available through pip or conda.
I've spent hours trying to find a solution, but to no avail. On pip, he package information returned from pyfmi.check_packages()
is:
PyFMI version ................ 2.5
Platform ..................... linux
Python version ............... 3.8.5
Dependencies:
Package Version
------- -------
assimulo...................... 3.0
Cython........................ 0.29.22
lxml.......................... 4.5.0
matplotlib.................... 3.1.2
numpy......................... 1.17.4
scipy......................... 1.6.1
and on conda it's
PyFMI version ................ 2.5
Platform ..................... linux
Python version ............... 3.8.5
Dependencies:
Package Version
------- -------
assimulo...................... 3.0
Cython........................ 0.29.22
lxml.......................... 4.6.2
matplotlib.................... 3.3.4
numpy......................... 1.20.1
scipy......................... 1.6.1
Note: I've tried install version PyFMI 2.8.5 via conda, but I always seem to end up with 2.5 regardless of what I try.
Does anyone have any suggestions? Many thanks for any help!
Upvotes: 0
Views: 133
Reputation: 21
I realise now why the wrong version of the package was being loaded. After uninstalling the pip version (2.5) the conda version (2.8.5) became visible, see below (updated after fixing second issue). Of course, now I have a different problem, but I'll document that in a different thread... it turned out to be a similar issue. I had an outdated Assimulo package installed in pip, which when uninstalled, allowed the conda version to be used correctly. I'm leaving the record of my solution visible in the hope that someone else in my position might benefit from it.
Performing pyfmi package check
==============================
PyFMI version ................ 2.8.5
Platform ..................... linux
Python version ............... 3.8.5
Dependencies:
Package Version
------- -------
assimulo...................... 3.2.3
Cython........................ 0.29.22
lxml.......................... 4.6.2
matplotlib.................... 3.3.4
numpy......................... 1.20.1
scipy......................... 1.6.1
Upvotes: 1