Ubuntu 18.04中python3环境中的PyFMI

2024-05-15 16:51:44 发布

您现在位置:Python中文网/ 问答频道 /正文

我的目标是能够在Ubuntu18.04中运行OpenModelica生成的FMU,然后在Python3环境中使用PyFMI运行这些功能。在

我遵循PyFMI安装的概要https://jmodelica.org/pyfmi/installation.html。在

到目前为止,我已经使用Conda成功地安装了Python3、Numpy、Scipy、lxml和其他一些包,并使其能够与我的一些Python示例一起工作。但我希望你能给我一些详细的建议

  1. 安装FMI库-我不知道如何设置标志fmil home
  2. 安装Assimulo

在那之后,我想我们准备好从安装大纲开始 “Python设置.py安装-fmil home=/path/to/fmil“

感谢一些基本的建议!在


Tags: httpsorg功能目标home环境installation建议
1条回答
网友
1楼 · 发布于 2024-05-15 16:51:44

我必须把所有的东西都编译好,这样conda可能会是一个更简单的解决方案。这对我很有效:

# change myUser to your user in the code below!
# install the dependencies (maybe you need more, I might have installed some already)
pip3 install numpy
pip3 install Cython
# get FMIL and build it
git clone https://github.com/modelon-community/fmi-library
cd fmi-library
mkdir build-fmil
cd build-fmil
cmake -DFMILIB_INSTALL_PREFIX=/home/myUser/fmil ..
make install test
# now you should have the FMIL library in:
# /home/myUser/fmil
# export that to terminal before installing PyFMI
export FMIL_HOME=/home/myUser/fmil

# get and install sundials
wget https://computing.llnl.gov/projects/sundials/download/sundials-3.0.0.tar.gz
tar -xf sundials-3.0.0.tar.gz
cd sundials-3.0.0
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=/home/myUser/sundials ..
make install

# get and install lapack and blas
https://github.com/Reference-LAPACK/lapack/archive/v3.9.0.tar.gz
tar -xf v3.9.0.tar.gz
cd lapack-3.9.0/
mkdir build
cmake -DCMAKE_INSTALL_PREFIX=/home/myUser/lapack ..
make install

# get Assimulo
git clone https://github.com/modelon-community/Assimulo
cd Assimulo/
sudo python3 setup.py install  sundials-home=/home/myUser/sundials  blas-home=/home/myUser/lapack/lib  lapack-home=/home/myUser/lapack

# get PyFMI
git clone https://github.com/modelon-community/PyFMI/
cd PyFMI
sudo python3 setup.py install  fmil-home=/home/myUser/fmil

# now you should have everything installed for your myUser
# you need to do:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/myUser/sundials/lib/
# before running PyFMI as all these libraries are installed for the local user
# note that you can install all these at the system level if you want, just do:
# -DCMAKE_INSTALL_PREFIX=/usr/local and -DFMILIB_INSTALL_PREFIX=/usr/local

相关问题 更多 >