在自己的物理机上面本来已经非常顺利的安装上dlib==19.15了,今天打算搭一个docker给实习生用,
docker环境是比较纯净的ubuntu14.04,自带python2.7.6,自己手动安装完pip和cmake3.6.3,但是用
pip install dlib
命令行安装一直报错:
Scanning dependencies of target dlib_python
[ 83%] Building CXX object CMakeFiles/dlib_python.dir/src/dlib.cpp.o
[ 84%] Building CXX object CMakeFiles/dlib_python.dir/src/matrix.cpp.o
[ 84%] Building CXX object CMakeFiles/dlib_python.dir/src/vector.cpp.o
[ 85%] Building CXX object CMakeFiles/dlib_python.dir/src/svm_c_trainer.cpp.o
[ 86%] Building CXX object CMakeFiles/dlib_python.dir/src/svm_rank_trainer.cpp.o
[ 86%] Building CXX object CMakeFiles/dlib_python.dir/src/decision_functions.cpp.o
In file included from /tmp/pip_build_root/dlib/dlib/external/pybind11/include/pybind11/pytypes.h:12:0,
from /tmp/pip_build_root/dlib/dlib/external/pybind11/include/pybind11/cast.h:13,
from /tmp/pip_build_root/dlib/dlib/external/pybind11/include/pybind11/attr.h:13,
from /tmp/pip_build_root/dlib/dlib/external/pybind11/include/pybind11/pybind11.h:43,
from /tmp/pip_build_root/dlib/dlib/../dlib/python/pybind_utils.h:6,
from /tmp/pip_build_root/dlib/dlib/../dlib/python.h:6,
from /tmp/pip_build_root/dlib/tools/python/src/opaque_types.h:6,
from /tmp/pip_build_root/dlib/tools/python/src/vector.cpp:4:
/tmp/pip_build_root/dlib/dlib/external/pybind11/include/pybind11/detail/common.h:111:20: fatal error: Python.h: No such file or directory
#include <Python.h>
^
compilation terminated.
[ 87%] Building CXX object CMakeFiles/dlib_python.dir/src/other.cpp.o
[ 88%] Building CXX object CMakeFiles/dlib_python.dir/src/basic.cpp.o
In file included from /tmp/pip_build_root/dlib/dlib/external/pybind11/include/pybind11/pytypes.h:12:0,
from /tmp/pip_build_root/dlib/dlib/external/pybind11/include/pybind11/cast.h:13,
from /tmp/pip_build_root/dlib/dlib/external/pybind11/include/pybind11/attr.h:13,
from /tmp/pip_build_root/dlib/dlib/external/pybind11/include/pybind11/pybind11.h:43,
from /tmp/pip_build_root/dlib/dlib/../dlib/python/pybind_utils.h:6,
from /tmp/pip_build_root/dlib/dlib/../dlib/python.h:6,
from /tmp/pip_build_root/dlib/tools/python/src/opaque_types.h:6,
from /tmp/pip_build_root/dlib/tools/python/src/dlib.cpp:4:
/tmp/pip_build_root/dlib/dlib/external/pybind11/include/pybind11/detail/common.h:111:20: fatal error: Python.h: No such file or directory
#include <Python.h>
^
compilation terminated.
In file included from /tmp/pip_build_root/dlib/dlib/external/pybind11/include/pybind11/pytypes.h:12:0,
from /tmp/pip_build_root/dlib/dlib/external/pybind11/include/pybind11/cast.h:13,
from /tmp/pip_build_root/dlib/dlib/external/pybind11/include/pybind11/attr.h:13,
from /tmp/pip_build_root/dlib/dlib/external/pybind11/include/pybind11/pybind11.h:43,
from /tmp/pip_build_root/dlib/dlib/../dlib/python/pybind_utils.h:6,
from /tmp/pip_build_root/dlib/dlib/../dlib/python.h:6,
from /tmp/pip_build_root/dlib/tools/python/src/opaque_types.h:6,
from /tmp/pip_build_root/dlib/tools/python/src/decision_functions.cpp:4:
/tmp/pip_build_root/dlib/dlib/external/pybind11/include/pybind11/detail/common.h:111:20: fatal error: Python.h: No such file or directory
#include <Python.h>
^
compilation terminated.
In file included from /tmp/pip_build_root/dlib/dlib/external/pybind11/include/pybind11/pytypes.h:12:0,
from /tmp/pip_build_root/dlib/dlib/external/pybind11/include/pybind11/cast.h:13,
from /tmp/pip_build_root/dlib/dlib/external/pybind11/include/pybind11/attr.h:13,
from /tmp/pip_build_root/dlib/dlib/external/pybind11/include/pybind11/pybind11.h:43,
from /tmp/pip_build_root/dlib/dlib/../dlib/python/pybind_utils.h:6,
from /tmp/pip_build_root/dlib/dlib/../dlib/python.h:6,
from /tmp/pip_build_root/dlib/tools/python/src/opaque_types.h:6,
from /tmp/pip_build_root/dlib/tools/python/src/matrix.cpp:4:
/tmp/pip_build_root/dlib/dlib/external/pybind11/include/pybind11/detail/common.h:111:20: fatal error: Python.h: No such file or directory
#include <Python.h>
^
compilation terminated.
In file included from /tmp/pip_build_root/dlib/dlib/external/pybind11/include/pybind11/pytypes.h:12:0,
from /tmp/pip_build_root/dlib/dlib/external/pybind11/include/pybind11/cast.h:13,
from /tmp/pip_build_root/dlib/dlib/external/pybind11/include/pybind11/attr.h:13,
from /tmp/pip_build_root/dlib/dlib/external/pybind11/include/pybind11/pybind11.h:43,
from /tmp/pip_build_root/dlib/dlib/../dlib/python/pybind_utils.h:6,
from /tmp/pip_build_root/dlib/dlib/../dlib/python.h:6,
from /tmp/pip_build_root/dlib/tools/python/src/opaque_types.h:6,
from /tmp/pip_build_root/dlib/tools/python/src/svm_c_trainer.cpp:4:
/tmp/pip_build_root/dlib/dlib/external/pybind11/include/pybind11/detail/common.h:111:20: fatal error: Python.h: No such file or directory
#include <Python.h>
^
compilation terminated.
In file included from /tmp/pip_build_root/dlib/dlib/external/pybind11/include/pybind11/pytypes.h:12:0,
from /tmp/pip_build_root/dlib/dlib/external/pybind11/include/pybind11/cast.h:13,
from /tmp/pip_build_root/dlib/dlib/external/pybind11/include/pybind11/attr.h:13,
from /tmp/pip_build_root/dlib/dlib/external/pybind11/include/pybind11/pybind11.h:43,
from /tmp/pip_build_root/dlib/dlib/../dlib/python/pybind_utils.h:6,
from /tmp/pip_build_root/dlib/dlib/../dlib/python.h:6,
from /tmp/pip_build_root/dlib/tools/python/src/basic.cpp:3:
/tmp/pip_build_root/dlib/dlib/external/pybind11/include/pybind11/detail/common.h:111:20: fatal error: Python.h: No such file or directory
#include <Python.h>
^
compilation terminated.
In file included from /tmp/pip_build_root/dlib/dlib/external/pybind11/include/pybind11/pytypes.h:12:0,
from /tmp/pip_build_root/dlib/dlib/external/pybind11/include/pybind11/cast.h:13,
from /tmp/pip_build_root/dlib/dlib/external/pybind11/include/pybind11/attr.h:13,
from /tmp/pip_build_root/dlib/dlib/external/pybind11/include/pybind11/pybind11.h:43,
from /tmp/pip_build_root/dlib/dlib/../dlib/python/pybind_utils.h:6,
from /tmp/pip_build_root/dlib/dlib/../dlib/python.h:6,
from /tmp/pip_build_root/dlib/tools/python/src/opaque_types.h:6,
from /tmp/pip_build_root/dlib/tools/python/src/other.cpp:4:
/tmp/pip_build_root/dlib/dlib/external/pybind11/include/pybind11/detail/common.h:111:20: fatal error: Python.h: No such file or directory
#include <Python.h>
^
compilation terminated.
make[2]: *** [CMakeFiles/dlib_python.dir/src/vector.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
In file included from /tmp/pip_build_root/dlib/dlib/external/pybind11/include/pybind11/pytypes.h:12:0,
from /tmp/pip_build_root/dlib/dlib/external/pybind11/include/pybind11/cast.h:13,
from /tmp/pip_build_root/dlib/dlib/external/pybind11/include/pybind11/attr.h:13,
from /tmp/pip_build_root/dlib/dlib/external/pybind11/include/pybind11/pybind11.h:43,
from /tmp/pip_build_root/dlib/dlib/../dlib/python/pybind_utils.h:6,
from /tmp/pip_build_root/dlib/dlib/../dlib/python.h:6,
from /tmp/pip_build_root/dlib/tools/python/src/opaque_types.h:6,
from /tmp/pip_build_root/dlib/tools/python/src/svm_rank_trainer.cpp:4:
/tmp/pip_build_root/dlib/dlib/external/pybind11/include/pybind11/detail/common.h:111:20: fatal error: Python.h: No such file or directory
#include <Python.h>
^
compilation terminated.
make[2]: *** [CMakeFiles/dlib_python.dir/src/dlib.cpp.o] Error 1
make[2]: *** [CMakeFiles/dlib_python.dir/src/matrix.cpp.o] Error 1
make[2]: *** [CMakeFiles/dlib_python.dir/src/decision_functions.cpp.o] Error 1
make[2]: *** [CMakeFiles/dlib_python.dir/src/svm_c_trainer.cpp.o] Error 1
make[2]: *** [CMakeFiles/dlib_python.dir/src/basic.cpp.o] Error 1
make[2]: *** [CMakeFiles/dlib_python.dir/src/other.cpp.o] Error 1
make[2]: *** [CMakeFiles/dlib_python.dir/src/svm_rank_trainer.cpp.o] Error 1
make[1]: *** [CMakeFiles/dlib_python.dir/all] Error 2
make: *** [all] Error 2
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip_build_root/dlib/setup.py", line 257, in <module>
'Topic :: Software Development',
File "/usr/lib/python2.7/distutils/core.py", line 151, in setup
dist.run_commands()
File "/usr/lib/python2.7/distutils/dist.py", line 953, in run_commands
self.run_command(cmd)
File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/usr/lib/python2.7/dist-packages/setuptools/command/install.py", line 53, in run
return _install.run(self)
File "/usr/lib/python2.7/distutils/command/install.py", line 601, in run
self.run_command('build')
File "/usr/lib/python2.7/distutils/cmd.py", line 326, in run_command
self.distribution.run_command(command)
File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/usr/lib/python2.7/distutils/command/build.py", line 128, in run
self.run_command(cmd_name)
File "/usr/lib/python2.7/distutils/cmd.py", line 326, in run_command
self.distribution.run_command(command)
File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/tmp/pip_build_root/dlib/setup.py", line 133, in run
self.build_extension(ext)
File "/tmp/pip_build_root/dlib/setup.py", line 173, in build_extension
subprocess.check_call(cmake_build, cwd=build_folder)
File "/usr/lib/python2.7/subprocess.py", line 540, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['cmake', '--build', '.', '--config', 'Release', '--', '-j8']' returned non-zero exit status 2
----------------------------------------
Cleaning up...
Command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip_build_root/dlib/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-UkWNiZ-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /tmp/pip_build_root/dlib
Storing debug log for failure in /root/.pip/pip.log
搜了一大圈内容,看到遇到这个问题的还不少,比如这个:
https://segmentfault.com/q/1010000014501717
后来搜到了
https://www.cnblogs.com/eating-gourd/p/8578007.html
用 apt-get install python-dev完美解决
希望对大家有用。