环境配置对应的Github:Multi-agent Motion Planning from Signal Temporal Logic Specifications
1. 直接pip安装:
pip install pypoman
然后报错。。。
2. 报错原因:
这个库主要依赖:pycddlib 和 cvxopt.
- 对于pycddlib: 会报错无法找到 “gmp.h”:
fatal error: ‘gmp.h’ file not found
#include “gmp.h”
^~~~~~~
1 error generated.
error: command ‘/usr/bin/clang’ failed with exit code 1
- 对于cvxopt: 会报错无法找到 #include “umfpack.h”:
fatal error: ‘umfpack.h’ file not found
#include “umfpack.h”
^~~~~~~~~~~
1 error generated.
error: command ‘/usr/bin/clang’ failed with exit code 1
[end of output]
现在针对这两个问题单独说明。
1) pycddlib:
Ubuntu
根据Github上的提示解决方法(本人非ubuntu系统,未尝试):
sudo apt-get install libgmp-dev
pip3 install pypoman
MacOS
首先确保自己安装了gmp:
brew install gmp
pip3 install pycddlib
但是再装的时候仍旧还是无法找到h文件,于是:
find /usr /opt -name "gmp.h"
find: /usr/sbin/authserver: Permission denied
/opt/homebrew/include/gmp.h
/opt/homebrew/Cellar/gmp/6.2.1_1/include/gmp.h
根据路径进行环境配置后再安装:
CFLAGS=-I/opt/homebrew/opt/gmp/include
LDFLAGS=-L/opt/homebrew/opt/gmp/lib
pip3 install pycddlib
若上述方法还不成功,可以再尝试:
```bash
export C_INCLUDE_PATH=$C_INCLUDE_PATH:/opt/homebrew/Cellar/gmp/6.2.1_1/include
export LIBRARY_PATH=$LIBRARY_PATH:/opt/homebrew/Cellar/gmp/6.2.1_1/lib
pip3 install pycddlib
即可安装成功。
## 2) cvxopt
类似于上面的解决方法,也需要环境配置。由此可知,当自己明明安装了lib,但是还是无法找到文件,即可考虑配置一下环境路径。
同样首先查找本地是否存在h文件:
```bash
find /usr /opt -name "umfpack.h"
find: /usr/sbin/authserver: Permission denied
/opt/homebrew/include/umfpack.h
/opt/homebrew/Cellar/suite-sparse/5.13.0/include/umfpack.h
没有的话,先安装suite-sparse,再重新查找:
brew install suite-sparse
根据路径进行环境配置后再安装:
CVXOPT_SUITESPARSE_LIB_DIR=/opt/homebrew/Cellar/suite-sparse/5.13.0/lib/
CVXOPT_SUITESPARSE_INC_DIR=/opt/homebrew/Cellar/suite-sparse/5.13.0/include/
pip3 install cvxopt
即可安装成功。
最后:
pip3 install pypoman
即可成功安装 pypoman。
此处总结其他可能遇到的找不到文件的情况时,所用到的路径配置,请根据自身路径进行部分修改:
CVXOPT_SUITESPARSE_LIB_DIR=/opt/homebrew/Cellar/suite-sparse/7.0.1/lib/ \
CVXOPT_SUITESPARSE_INC_DIR=/opt/homebrew/Cellar/suite-sparse/7.0.1/include/ \
CVXOPT_GSL_LIB_DIR=/opt/homebrew/Cellar/gsl/2.7.1/lib/ \
CVXOPT_GSL_INC_DIR=/opt/homebrew/Cellar/gsl/2.7.1/include/ \
CVXOPT_FFTW_LIB_DIR=/opt/homebrew/Cellar/fftw/3.3.10_1/lib/ \
CVXOPT_FFTW_INC_DIR=/opt/homebrew/Cellar/fftw/3.3.10_1/include/ \
CVXOPT_GLPK_LIB_DIR=/opt/homebrew/Cellar/glpk/5.0/lib/ \
CVXOPT_GLPK_INC_DIR=/opt/homebrew/Cellar/glpk/5.0/include/ \
3. 最后一坑:
虽然成功安装了pypoman,但是在import的时候仍旧会报错:
Traceback (most recent call last):
File “”, line 1, in
File “/opt/homebrew/lib/python3.9/site-packages/pypoman/init.py”, line 24, in
from .intersection import intersect_line_cylinder
File “/opt/homebrew/lib/python3.9/site-packages/pypoman/intersection.py”, line 22, in
from scipy.spatial import ConvexHull
File “/opt/homebrew/lib/python3.9/site-packages/scipy/spatial/init.py”, line 107, in
from ._procrustes import procrustes
File “/opt/homebrew/lib/python3.9/site-packages/scipy/spatial/_procrustes.py”, line 9, in
from scipy.linalg import orthogonal_procrustes
File “/opt/homebrew/lib/python3.9/site-packages/scipy/linalg/init.py”, line 198, in
from ._misc import *
File “/opt/homebrew/lib/python3.9/site-packages/scipy/linalg/_misc.py”, line 3, in
from .blas import get_blas_funcs
File “/opt/homebrew/lib/python3.9/site-packages/scipy/linalg/blas.py”, line 213, in
from scipy.linalg import _fblas
ImportError: dlopen(/opt/homebrew/lib/python3.9/site-packages/scipy/linalg/_fblas.cpython-39-darwin.so, 2): Library not loaded: /opt/homebrew/opt/gcc/lib/gcc/11/libgfortran.5.dylib
Referenced from: /opt/homebrew/lib/python3.9/site-packages/scipy/linalg/_fblas.cpython-39-darwin.so
Reason: image not found
查看发现可能是scipy的问题,于是考虑安装/重新安装scipy:
pip3 install --upgrade --force-reinstall scipy
仍旧报错:
Preparing metadata (pyproject.toml) … error
error: subprocess-exited-with-error
…(省略一堆不太看得懂的)
…/…/scipy/meson.build:131:0: ERROR: Dependency “OpenBLAS” not found, tried pkgconfig and framework (看到重点)
…(后续仍旧有超长报错。。。)
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
× Encountered error while generating package metadata.
╰─> See above for output.
note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
首先安装:
brew install openblas
同样,出现安装 openblas后仍旧找不到,则查找对应的安装信息:
brew info openblas
会看到它的输出有:
because macOS provides BLAS in Accelerate.framework.
For compilers to find openblas you may need to set:
export LDFLAGS=“-L/opt/homebrew/opt/openblas/lib”
export CPPFLAGS=“-I/opt/homebrew/opt/openblas/include”
For pkg-config to find openblas you may need to set:
export PKG_CONFIG_PATH=“/opt/homebrew/opt/openblas/lib/pkgconfig”
export PKG_CONFIG_PATH="/opt/homebrew/opt/openblas/lib/pkgconfig"
pip3 install scipy
即可安装成功。
注意,如果 from scipy.spatial import CovexHul 碰到报错
ImportError: cannot import name ‘CovexHull’ from ‘scipy.spatial’ (unknown location)
则需要注意自己scipy的版本信息,考虑升级pip,并重新安装scipy 版本>=0.12.0即可,我的版本scipy-1.9.3可用。