在编译caffe过程中遇到的问题:libboost_python.so: undefined reference to `PyUnicode_InternFromString'

安装caffe时遇到这个错误,如下图所示:

简单粗暴的解决办法,进入到libboost_python.so所在root,删除当前的libboost_python.so,再重新生成新的链接

cd /usr/lib/x86_64-linux-gnu/
sudo rm libboost_python.so
sudo ln -s libboost_python-py27.so libboost_python.so

解决问题。

重新编译,记得先clean,再编译!

编译成功。 

如果上述方法没有解决,查看你cmake编译时python版本,

 

如果cmake配置的是anaconda中的python,也会出现上述错误,修改环境变量,将python版本替换为自己配置的python如下:

(1)sudo gedit .bashrc

(2)注释:

__conda_setup="$('/home/whf/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
    eval "$__conda_setup"
else
    if [ -f "/home/whf/anaconda3/etc/profile.d/conda.sh" ]; then
        . "/home/whf/anaconda3/etc/profile.d/conda.sh"
    else
        export PATH="/home/whf/anaconda3/bin:$PATH"
    fi
fi
unset __conda_setup

在底部添加你的python所在位置:

PATH="/usr/lib/python3.5/site-packages:${PATH}"
export PATH
PYTHONPATH="/usr/lib/python3.5/site-packages:${PATH}"
export PYTHONPATH

重新打开终端编译,如下图所示,修改成功:

再进行编译,成功!

 

posted @ 2020-04-14 14:53  我们都是大好青年  阅读(2970)  评论(0编辑  收藏  举报