安装dlib时失败,报错如下:
$pip install dlib
Defaulting to user installation because normal site-packages is not writeable
Looking in indexes: https://mirrors.huaweicloud.com/repository/pypi/simple
Collecting dlib
Downloading https://mirrors.huaweicloud.com/repository/pypi/packages/3c/07/a2693a94ac678c442c4cfe269d24f63053b14410ef2d09957a762eeb4b8e/dlib-19.24.6.tar.gz (3.4 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.4/3.4 MB 27.1 MB/s eta 0:00:00
Preparing metadata (setup.py) ... error
error: subprocess-exited-with-error
× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [44 lines of output]
running egg_info
creating /tmp/pip-pip-egg-info-t2gd3sz_/dlib.egg-info
writing /tmp/pip-pip-egg-info-t2gd3sz_/dlib.egg-info/PKG-INFO
writing dependency_links to /tmp/pip-pip-egg-info-t2gd3sz_/dlib.egg-info/dependency_links.txt
writing top-level names to /tmp/pip-pip-egg-info-t2gd3sz_/dlib.egg-info/top_level.txt
writing manifest file '/tmp/pip-pip-egg-info-t2gd3sz_/dlib.egg-info/SOURCES.txt'
reading manifest file '/tmp/pip-pip-egg-info-t2gd3sz_/dlib.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
no previously-included directories found matching 'tools/python/build*'
no previously-included directories found matching 'dlib/cmake_utils/*/build*'
no previously-included directories found matching 'dlib/test'
warning: no previously-included files matching '*.pyc' found anywhere in distribution
Traceback (most recent call last):
File "<string>", line 2, in <module>
File "<pip-setuptools-caller>", line 34, in <module>
File "/tmp/pip-install-t2sl_h7x/dlib_b813669f1b0743f98721752d0092e03a/setup.py", line 243, in <module>
setup(
File "/home/pan/.local/lib/python3.8/site-packages/setuptools/__init__.py", line 117, in setup
return distutils.core.setup(**attrs)
File "/home/pan/.local/lib/python3.8/site-packages/setuptools/_distutils/core.py", line 183, in setup
return run_commands(dist)
File "/home/pan/.local/lib/python3.8/site-packages/setuptools/_distutils/core.py", line 199, in run_commands
dist.run_commands()
File "/home/pan/.local/lib/python3.8/site-packages/setuptools/_distutils/dist.py", line 954, in run_commands
self.run_command(cmd)
File "/home/pan/.local/lib/python3.8/site-packages/setuptools/dist.py", line 950, in run_command
super().run_command(command)
File "/home/pan/.local/lib/python3.8/site-packages/setuptools/_distutils/dist.py", line 973, in run_command
cmd_obj.run()
File "/home/pan/.local/lib/python3.8/site-packages/setuptools/command/egg_info.py", line 311, in run
self.find_sources()
File "/home/pan/.local/lib/python3.8/site-packages/setuptools/command/egg_info.py", line 319, in find_sources
mm.run()
File "/home/pan/.local/lib/python3.8/site-packages/setuptools/command/egg_info.py", line 545, in run
self.prune_file_list()
File "/home/pan/.local/lib/python3.8/site-packages/setuptools/command/sdist.py", line 161, in prune_file_list
super().prune_file_list()
File "/home/pan/.local/lib/python3.8/site-packages/setuptools/_distutils/command/sdist.py", line 380, in prune_file_list
base_dir = self.distribution.get_fullname()
File "/home/pan/.local/lib/python3.8/site-packages/setuptools/_core_metadata.py", line 267, in get_fullname
return _distribution_fullname(self.get_name(), self.get_version())
File "/home/pan/.local/lib/python3.8/site-packages/setuptools/_core_metadata.py", line 285, in _distribution_fullname
canonicalize_version(version, strip_trailing_zero=False),
TypeError: canonicalize_version() got an unexpected keyword argument 'strip_trailing_zero'
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
× Encountered error while generating package metadata.
╰─> See above for output.
note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
查到是因为setuptools工具版本不对。
版本太高,需要重新安装一个。
$ pip list | grep setup
setuptools 75.1.0
$ pip install 'setuptools<58.0.0'
Defaulting to user installation because normal site-packages is not writeable
Looking in indexes: https://mirrors.huaweicloud.com/repository/pypi/simple
Collecting setuptools<58.0.0
Downloading https://mirrors.huaweicloud.com/repository/pypi/packages/4b/b9/71687c5d2034c863db1db2e0704f5e27581ff3cb44d7f293968c5e08ceb3/setuptools-57.5.0-py3-none-any.whl (819 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 819.3/819.3 kB 14.8 MB/s eta 0:00:00
Installing collected packages: setuptools
Attempting uninstall: setuptools
Found existing installation: setuptools 75.1.0
Uninstalling setuptools-75.1.0:
Successfully uninstalled setuptools-75.1.0
Successfully installed setuptools-57.5.0
再次安装dlib,成功
$ pip install dlib
Defaulting to user installation because normal site-packages is not writeable
Looking in indexes: https://mirrors.huaweicloud.com/repository/pypi/simple
Collecting dlib
Downloading https://mirrors.huaweicloud.com/repository/pypi/packages/3c/07/a2693a94ac678c442c4cfe269d24f63053b14410ef2d09957a762eeb4b8e/dlib-19.24.6.tar.gz (3.4 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.4/3.4 MB 26.5 MB/s eta 0:00:00
Preparing metadata (setup.py) ... done
Building wheels for collected packages: dlib
Building wheel for dlib (setup.py) ... done
Created wheel for dlib: filename=dlib-19.24.6-cp38-cp38-linux_x86_64.whl size=4126251 sha256=6c967d8d5c66dbe9e7f1d4fbec9e4a11e3ebac60b2f095d589eb7c240c2099e8
Stored in directory: /home/pan/.cache/pip/wheels/9a/35/5e/88273b88fbc6923cf3cace8abdd556d50082dbdad89438cc6a
Successfully built dlib
Installing collected packages: dlib
Successfully installed dlib-19.24.6