chink
chink

Reputation: 1643

Error while loading a fmu in python with pyfmi library

I have installed PyFMI library and trying to load a fmu created by GT-Suite in python.

I am following this tutorial of jmodelica :

https://jmodelica.org/pyfmi/tutorial.html

# Import the load function (load_fmu)
from pyfmi import load_fmu

this set gives a warning

Could not find cannot import name 'radau5' from 'assimulo.lib' (C:\Users\chinn\Anaconda3\lib\site-packages\assimulo\lib\__init__.py)
Could not find cannot import name 'dopri5' from 'assimulo.lib' (C:\Users\chinn\Anaconda3\lib\site-packages\assimulo\lib\__init__.py)
Could not find cannot import name 'rodas' from 'assimulo.lib' (C:\Users\chinn\Anaconda3\lib\site-packages\assimulo\lib\__init__.py)
Could not find cannot import name 'odassl' from 'assimulo.lib' (C:\Users\chinn\Anaconda3\lib\site-packages\assimulo\lib\__init__.py)
Could not find ODEPACK functions.
Could not find RADAR5
Could not find GLIMDA.

When I try to load the fmu model

#Load the FMU
model = load_fmu('AHUdirectRPm.fmu')

I get an error

Traceback (most recent call last):

  File "<ipython-input-2-77df09904b1e>", line 1, in <module>
    model = load_fmu('AHUdirectRPm.fmu')

  File "src\pyfmi\fmi.pyx", line 7899, in pyfmi.fmi.load_fmu

  File "src\pyfmi\fmi.pyx", line 2558, in pyfmi.fmi.FMUModelCS1.__init__

  File "src\pyfmi\fmi.pyx", line 1167, in pyfmi.fmi.FMUModelBase.__init__

  File "src\pyfmi\fmi.pyx", line 45, in pyfmi.fmi.encode

TypeError: latin_1_encode() argument 1 must be str, not bytes

Can someone help me with this. What to do?

output of 'pyfmi.check_packages()'


Performing pyfmi package check 
==============================

PyFMI version ................ 2.5                           

Platform ..................... win32                         

Python version ............... 3.7.3                         



Dependencies: 

Package                        Version                       
-------                        -------                       
assimulo...................... 3.0                           
Cython........................ 0.29.6                        
lxml.......................... 4.3.2                         
matplotlib.................... 3.0.3                         
numpy......................... 1.16.2                        
scipy......................... 1.2.1                         
wxPython...................... --              Package missing - Warning issued, see details below
pyreadline.................... 2.1                           
setuptools.................... 40.8.0                        


Warnings 
--------

-- The package wxPython could not be found. This package is needed to be able to use the plot-GUI.

Upvotes: 2

Views: 1762

Answers (2)

Christian Winther
Christian Winther

Reputation: 1123

The error:

Traceback (most recent call last):

   File "<ipython-input-2-77df09904b1e>", line 1, in <module>
       model = load_fmu('AHUdirectRPm.fmu')
   File "src\pyfmi\fmi.pyx", line 7899, in pyfmi.fmi.load_fmu
   File "src\pyfmi\fmi.pyx", line 2558, in pyfmi.fmi.FMUModelCS1.__init__
   File "src\pyfmi\fmi.pyx", line 1167, in pyfmi.fmi.FMUModelBase.__init__
   File "src\pyfmi\fmi.pyx", line 45, in pyfmi.fmi.encode

TypeError: latin_1_encode() argument 1 must be str, not bytes

Is due to an issue with the internal encoding in PyFMI and will be fixed in later versions of PyFMI (>2.5).

Upvotes: 0

chink
chink

Reputation: 1643

Installing the pyfmi package with pip is giving the error.All the dependencies have to be downloaded correctly. Installing through conda doesn't require all this. Installed through conda by

conda install -c conda-forge pyfmi 

This has worked well for me

Upvotes: 1

Related Questions