安装medpy with graphcut support

安装medpy时发现没有graphcut支持。通过如下命令查看安装的详细细节:

pip install medpy --no-cache-dir --log install.log

查看install.log发现问题如下:

g++ -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -g -fwrapv -O2 -Wl,-Bsymbolic-functions -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 build/temp.linux-x86_64-3.10/lib/maxflow/src/graph.o build/temp.linux-x86_64-3.10/lib/maxflow/src/maxflow.o build/temp.linux-x86_64-3.10/lib/maxflow/src/wrapper.o -lboost_python3 -o build/lib.linux-x86_64-3.10/medpy/graphcut/maxflow.cpython-310-x86_64-linux-gnu.so

/usr/bin/ld: cannot find -lboost_python3: No such file or directory

检测系统发现已经安装了boost python. 采用如下命令解决:

  1. 增加软链接:
ln -s /path/to/boost/lib/libboost_python36.so /path/to/boost/lib/libboost_python3.so

如果有root权限且boost通过sudo apt install安装, 则修改:

sudo ln -s /usr/lib/x86_64-linux-gnu/libboost_python36.so /usr/lib/x86_64-linux-gnu/libboost_python3.so
  1. 添加目录使得/usr/bin/ld能识别:
export LDFLAGS=-L/path/to/boost/lib

完成之后再通过pip install medpy安装即可。测试是否成功:

from medpy import graphcut

你可能感兴趣的:(python,python)