Install pypoman on MACOS (M1)
创始人
2024-02-22 17:40:31
0

环境配置对应的Github:Multi-agent Motion Planning from Signal Temporal Logic Specifications

1. 直接pip安装:

pip install pypoman

然后报错。。。

2. 报错原因:

这个库主要依赖:pycddlib 和 cvxopt.

  1. 对于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

  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

即可安装成功。

2) cvxopt

类似于上面的解决方法,也需要环境配置。由此可知,当自己明明安装了lib,但是还是无法找到文件,即可考虑配置一下环境路径。

同样首先查找本地是否存在h文件:

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。

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可用。

相关内容

热门资讯

央行:实施一次性信用修复政策 人民财讯12月22日电,为积极应对新冠疫情后续影响,支持信用受损但积极还款的个人高效便捷重塑信用,助...
中国人民银行发布关于实施一次性... 中国人民银行发布关于实施一次性信用修复政策有关安排的通知,其中提到,对于2020年1月1日至2025...
支持个人信用重塑!央行发布一次... 本文转自【新华社】; 为支持信用受损但积极还款的个人高效便捷重塑信用,12月22日中国人民银行对外...
银河证券:短期关注防御性板块配... 银河证券指出,随着2026年即将开启,A股市场进入跨年布局的关键窗口,关注元旦前后的小躁动行情。20...
“以帮代赔”化解马啃秸秆纠纷 因主人不在家疏于看管,马儿多次跑到别人家地里啃食玉米秸秆。12月18日,娄烦县公安局盖家庄派出所民警...
怎样选到靠谱刑事律师?赵可律师... 靠谱刑事律师的衡量标准在寻找靠谱的刑事律师时,有多个衡量标准。 专业能力是关键,律师需具备扎实的法学...
吉林省刑辩律师哪家强?辛明律师... 吉林省刑辩律师的重要性在吉林省,刑事案件的复杂性和多样性使得刑辩律师的作用愈发凸显。 他们不仅要熟悉...
江苏多地推出公租房调换政策 就... 原题:就医养老更方便 按需调换更贴心 公租房也能“换着住” 公共租赁房是由政府提供支持,为中低收入困...
法治日报:跨境犯罪治理需要更完... 跨境犯罪呈现多重犯罪形态交织特征 各国代表建言 跨境犯罪治理需要更完善的司法保障 编者按 携手30年...