2

我已经安装了 PyFMI 库并尝试在 python 中加载由 GT-Suite 创建的 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.
4

2 回答 2

1

使用 pip 安装 pyfmi 包会报错。必须正确下载所有依赖项。通过 conda 安装不需要所有这些。通过 conda 安装

conda install -c conda-forge pyfmi 

这对我来说效果很好

于 2019-06-10T08:13:05.980 回答
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) 中修复。

于 2019-06-14T09:32:08.710 回答