我已经安装了PyFMI库,并尝试加载由GT-Suite在python中创建的fmu。
我正在关注jmodelica的本教程:
https://jmodelica.org/pyfmi/tutorial.html
# Import the load function (load_fmu)
from pyfmi import load_fmu
此设置发出警告
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.
当我尝试加载fmu模型时
#Load the FMU
model = load_fmu('AHUdirectRPm.fmu')
我遇到错误
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
有人可以帮我吗?该怎么办?
'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.
答案 0 :(得分:0)
使用pip安装pyfmi软件包会出现错误,必须正确下载所有依赖项。通过conda安装不需要所有这些。通过conda安装
conda install -c conda-forge pyfmi
这对我来说很好
答案 1 :(得分:0)
错误:
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
是由于PyFMI中的内部编码出现问题,将在更高版本的PyFMI(> 2.5)中修复。