安装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. 采用如下命令解决:
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
/usr/bin/ld
能识别:export LDFLAGS=-L/path/to/boost/lib
完成之后再通过pip install medpy
安装即可。测试是否成功:
from medpy import graphcut