user@ubuntu:~/aitool/project$ sudo pip install dlib
The directory '/home/user/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/user/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting dlib
Downloading https://files.pythonhosted.org/packages/35/8d/e4ddf60452e2fb1ce3164f774e68968b3f110f1cb4cd353235d56875799e/dlib-19.16.0.tar.gz (3.3MB)
100% |████████████████████████████████| 3.3MB 13kB/s
Installing collected packages: dlib
Running setup.py install for dlib ... error
Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-WuPSBd/dlib/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-kr7NLh/install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_py
package init file 'dlib/__init__.py' not found (or not a regular file)
running build_ext
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-WuPSBd/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 61, in run
return orig.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-install-WuPSBd/dlib/setup.py", line 127, in run
cmake_version = self.get_cmake_version()
File "/tmp/pip-install-WuPSBd/dlib/setup.py", line 123, in get_cmake_version
"\n*******************************************************************\n")
RuntimeError:
*******************************************************************
CMake must be installed to build the following extensions: dlib
*******************************************************************

Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-WuPSBd/dlib/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-kr7NLh/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-WuPSBd/dlib/
user@ubuntu:~/aitool/project$
解决:
user@ubuntu:~$ git clone https://github.com/davisking/dlib.git
Cloning into 'dlib'...
remote: Enumerating objects: 6, done.
remote: Counting objects: 100% (6/6), done.
remote: Compressing objects: 100% (6/6), done.
remote: Total 46714 (delta 0), reused 1 (delta 0), pack-reused 46708
Receiving objects: 100% (46714/46714), 21.92 MiB | 32.00 KiB/s, done.
Resolving deltas: 100% (32823/32823), done.
Checking connectivity... done.
user@ubuntu:~$
user@ubuntu:~/dlib/examples/build$ cmake ..
The program 'cmake' is currently not installed. You can install it by typing:
sudo apt install cmake
user@ubuntu:~/dlib/examples/build$ sudo apt install cmake
下载后解压安装Dlib
cd dlib/examples
mkdir build
cd build
cmake ..
cmake --build . --config Release
本文详细记录了在Ubuntu环境下使用pip安装Dlib库遇到的权限和依赖问题,包括缓存目录权限错误、缺少CMake等,并提供了通过克隆源码仓库并手动编译安装的解决方案。
3932

被折叠的 条评论
为什么被折叠?



