我正在按照本教程学习如何使用Python进行简单的面部识别。本教程依赖于我尝试安装的 dlib 库。但是,dlib 库依赖于 Boost 库并产生此错误:
-- Found PythonLibs: /Library/Frameworks/Python.framework/Versions/3.6/lib/libpython3.6.dylib (found suitable version "3.6.0", minimum required is "3.4")
-- *****************************************************************************************************
-- To compile Boost.Python yourself download boost from boost.org and then go into the boost root folder
-- and run these commands:
-- ./bootstrap.sh --with-libraries=python
-- ./b2
-- sudo ./b2 install
当我从 Boost 下载文件夹运行./bootstrap.sh --with-libraries=python
时,出现以下错误:
darwin.compile.c++ bin.v2/libs/python/build/darwin-4.2.1/release/threading-multi/numeric.o
In file included from libs/python/src/numeric.cpp:6:
In file included from ./boost/python/numeric.hpp:8:
In file included from ./boost/python/detail/prefix.hpp:13:
./boost/python/detail/wrap_python.hpp:50:11: fatal error: 'pyconfig.h' file not found
# include <pyconfig.h>
^
1 error generated.
"g++" -ftemplate-depth-128 -O3 -Wall -dynamic -gdwarf-2 -fexceptions -Wno-inline -fPIC -arch x86_64 -DBOOST_ALL_NO_LIB=1 -DBOOST_PYTHON_SOURCE -DNDEBUG -I"." -I"/Users/mikkeld/anaconda/include/python3.5" -c -o "bin.v2/libs/python/build/darwin-4.2.1/release/threading-multi/numeric.o" "libs/python/src/numeric.cpp"
我在这里有点迷茫,并尝试四处寻找而没有运气。谁能发现问题所在?
感谢这个解决方案和上面的一个,我通过以下方式找到了我的 python 包含链接:打开终端并运行:蟒蛇 --版本
将 3.7 替换为当前 Python 版本并运行:
python3.7-config --includes --libs
链接:
/Users/<username>/.pyenv/versions/3.6.7/Python.framework/Versions/3.6/include/python3.6m
并替换了我在下面C_INCLUDE_PATH
中找到的链接
编辑/etc/profile
,并将以下内容附加到文件中,您应该修改用于指定 python 标头的路径
C_INCLUDE_PATH=$C_INCLUDE_PATH:/usr/local/include/python3.6m
export C_INCLUDE_PATH
CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH:/usr/local/include/python3.6m
export CPLUS_INCLUDE_PATH
Source /etc/profile
再次编译它现在编译提升!
这是那些使用Anaconda的人的答案。
打开终端并运行:
python --version
替换当前 Python 版本的3.7
并运行:
python3.7-config --includes --libs
-I/home/victor/anaconda3/include/python3.7m -I/home/victor/anaconda3/include/python3.7m -lpython3.7m -lpthread -ldl -lutil -LRT -LM
现在,返回第一项并在~/.bashrc
上添加以下行:
export CPLUS_INCLUDE_PATH="$CPLUS_INCLUDE_PATH:/home/victor/anaconda3/include/python3.7m"
获取新的 bashrc 文件
source ~/.bashrc_profile
我在编译 boost 时也遇到了这个问题,以下是我的解决方案。
- 安装蟒蛇
-
编辑/etc/profile,并在文件后面附加,您应该修改用于指定 python 标头的路径
C_INCLUDE_PATH=$C_INCLUDE_PATH:/usr/local/include/python3.6m
出口C_INCLUDE_PATH
CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH:/usr/local/include/python3.6m
出口CPLUS_INCLUDE_PATH
-
来源/etc/profile
-
再次编译
它对我有用,希望你如此。
这是在 Ubuntu 18.04 上的 anaconda 的 boost 1.72 和 python 3.7 下对我有用的技术。
- 确保您的 anaconda 环境处于活动状态(路径中的正确 python(
- 在提升源树中,编辑文件
tools/build/src/tools/python.jam
- 查找第 547 行
includes ?= $(prefix)/include/python$(version) ;
- 替换为
includes ?= $(prefix)/include/python$(version)m ;
- 像往常一样
./bootstrap.sh
和./b2 install