我在其他网站和此处也看到过此错误,但提供的解决方案并未修复它。操作系统:Mendel GNU/Linux 5 (Eagle)(Debian)。当尝试安装时psutil
,我收到错误:
sudo pip3 install --upgrade psutil
Collecting psutil
Exception:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/pip/_internal/cli/base_command.py", line 143, in main
status = self.run(options, args)
File "/usr/lib/python3/dist-packages/pip/_internal/commands/install.py", line 338, in run
resolver.resolve(requirement_set)
File "/usr/lib/python3/dist-packages/pip/_internal/resolve.py", line 102, in resolve
self._resolve_one(requirement_set, req)
File "/usr/lib/python3/dist-packages/pip/_internal/resolve.py", line 256, in _resolve_one
abstract_dist = self._get_abstract_dist_for(req_to_install)
File "/usr/lib/python3/dist-packages/pip/_internal/resolve.py", line 209, in _get_abstract_dist_for
self.require_hashes
File "/usr/lib/python3/dist-packages/pip/_internal/operations/prepare.py", line 218, in prepare_linked_requirement
req.populate_link(finder, upgrade_allowed, require_hashes)
File "/usr/lib/python3/dist-packages/pip/_internal/req/req_install.py", line 164, in populate_link
self.link = finder.find_requirement(self, upgrade)
File "/usr/lib/python3/dist-packages/pip/_internal/index.py", line 572, in find_requirement
all_candidates = self.find_all_candidates(req.name)
File "/usr/lib/python3/dist-packages/pip/_internal/index.py", line 534, in find_all_candidates
self._package_versions(page.iter_links(), search)
File "/usr/lib/python3/dist-packages/pip/_internal/index.py", line 702, in _package_versions
v = self._link_package_versions(link, search)
File "/usr/lib/python3/dist-packages/pip/_internal/index.py", line 777, in _link_package_versions
support_this_python = check_requires_python(link.requires_python)
File "/usr/lib/python3/dist-packages/pip/_internal/utils/packaging.py", line 33, in check_requires_python
return python_version in requires_python_specifier
File "/usr/share/python-wheels/packaging-19.0-py2.py3-none-any.whl/packaging/specifiers.py", line 676, in __contains__
return self.contains(item)
File "/usr/share/python-wheels/packaging-19.0-py2.py3-none-any.whl/packaging/specifiers.py", line 681, in contains
item = parse(item)
File "/usr/share/python-wheels/packaging-19.0-py2.py3-none-any.whl/packaging/version.py", line 28, in parse
return Version(version)
File "/usr/share/python-wheels/packaging-19.0-py2.py3-none-any.whl/packaging/version.py", line 219, in __init__
match = self._regex.search(version)
TypeError: expected string or bytes-like object
我找不到该文件/usr/share/python-wheels/packaging-19.0-py2.py3-none-any.whl/packaging/version.py
(因为文件后面没有任何内容.whl
,但我猜测这packaging-19.0-py2.py3-none-any.whl
是一个依赖于 的轮子。所以我在我的系统中pip3
进行了搜索。version.py
$ sudo find / -name version.py
/usr/lib/python3/dist-packages/debianbts/version.py
/usr/lib/python3/dist-packages/pkg_resources/_vendor/packaging/version.py
/usr/lib/python3/dist-packages/chardet/version.py
/usr/lib/python3/dist-packages/numpy/version.py
/usr/lib/python3/dist-packages/numpy/ma/version.py
/usr/lib/python3/dist-packages/OpenGL/version.py
/usr/lib/python3/dist-packages/setuptools/version.py
/usr/lib/python3/dist-packages/setuptools/_vendor/packaging/version.py
/usr/lib/python2.7/distutils/version.py
/usr/lib/python2.7/dist-packages/pkg_resources/_vendor/packaging/version.py
/usr/lib/python2.7/dist-packages/IPython/utils/version.py
/usr/lib/python3.7/distutils/version.py
/usr/local/lib/python3.7/dist-packages/pydantic/version.py
/usr/local/lib/python3.7/dist-packages/websockets/version.py
/usr/local/lib/python3.7/dist-packages/flask_cors/version.py
/usr/local/lib/python3.7/dist-packages/packaging/version.py
/usr/share/python3/debpython/version.py
/usr/share/dh-python/dhpython/version.py
/usr/share/python/debpython/version.py
我编辑了两个具有 的文件packaging/version.py
,它们是:
/usr/local/lib/python3.7/dist-packages/packaging/version.py
这并不影响 pip3 install 的输出,更改是
match = self._regex.search(version)
:match = self._regex.search(str(version))
然后我继续更改其他文件/packaging/version.py
/usr/lib/python3/dist-packages/pkg_resources/_vendor/packaging/version.py
/usr/lib/python3/dist-packages/setuptools/_vendor/packaging/version.py
但一切都没有改变。我发现这可能是一个问题Debian 中的轮子(错误并不完全相同,但降级轮子似乎还可以?),但我不确定也不知道这会对我的系统造成多大影响(我之前遇到过包管理器问题,不得不删除我的linux 发行版,所以我要小心)。
编辑:pip3版本:
$ pip3 --version
pip 18.1 from /usr/lib/python3/dist-packages/pip (python 3.7)
编辑:尝试安装时出现此问题PyAccessPoint。由于某种原因,安装它艰难的道路,有效,但仍然没有解决这个问题,也没有解决未来的轮子问题:
sudo apt update && sudo apt --yes --force-yes install dnsmasq hostapd python3-dev unzip python3-pip && cd ~ && wget --output-document=pyaccesspoint-master.zip https://github.com/Goblenus/pyaccesspoint/archive/master.zip && unzip pyaccesspoint-master.zip && cd pyaccesspoint-master && sudo python3 setup.py install && cd ~ && sudo rm -rf pyaccesspoint-master.zip pyaccesspoint-master