我一直试图找出导致此错误的原因,但我尝试过的每个解决方案(从完全卸载python和pip到rm-ing某个文件夹)都无法工作:
系统信息:Ubuntu18.04.4LTS(GNU/Linux4.15.0-88-泛型x86_64)
python3 -V: Python3.6.9
$ pip3 install -R requirements.txt
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/pip/_vendor/__init__.py", line 33, in vendored
__import__(vendored_name, globals(), locals(), level=0)
ModuleNotFoundError: No module named 'pip._vendor.distro'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/bin/pip3", line 9, in
from pip import main
File "/usr/lib/python3/dist-packages/pip/__init__.py", line 22, in
from pip._vendor.requests.packages.urllib3.exceptions import DependencyWarning
File "/usr/lib/python3/dist-packages/pip/_vendor/__init__.py", line 67, in
vendored("distro")
File "/usr/lib/python3/dist-packages/pip/_vendor/__init__.py", line 36, in vendored
__import__(modulename, globals(), locals(), level=0)
File "", line 971, in _find_and_load
File "", line 955, in _find_and_load_unlocked
File "", line 656, in _load_unlocked
File "", line 626, in _load_backward_compatible
File "/usr/share/python-wheels/distro-1.0.1-py2.py3-none-any.whl/distro.py", line 1051, in
File "/usr/share/python-wheels/distro-1.0.1-py2.py3-none-any.whl/distro.py", line 595, in __init__
File "/usr/share/python-wheels/distro-1.0.1-py2.py3-none-any.whl/distro.py", line 932, in _get_lsb_release_info
subprocess.CalledProcessError: Command 'lsb_release -a' returned non-zero exit status 1.我试着确保皮普:
python3.8 -m ensurepip
Traceback (most recent call last):
File "/usr/lib/python3.8/runpy.py", line 193, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/lib/python3.8/runpy.py", line 86, in _run_code
exec(code, run_globals)
File "/usr/lib/python3.8/ensurepip/__main__.py", line 5, in
sys.exit(ensurepip._main())
File "/usr/lib/python3.8/ensurepip/__init__.py", line 200, in _main
return _bootstrap(
File "/usr/lib/python3.8/ensurepip/__init__.py", line 119, in _bootstrap
return _run_pip(args + [p[0] for p in _PROJECTS], additional_paths)
File "/usr/lib/python3.8/ensurepip/__init__.py", line 27, in _run_pip
import pip._internal
File "", line 259, in load_module
File "/tmp/tmp7_mor_ds/pip-19.2.3-py2.py3-none-any.whl/pip/_internal/__init__.py", line 40, in
File "", line 259, in load_module
File "/tmp/tmp7_mor_ds/pip-19.2.3-py2.py3-none-any.whl/pip/_internal/cli/autocompletion.py", line 8, in
File "", line 259, in load_module
File "/tmp/tmp7_mor_ds/pip-19.2.3-py2.py3-none-any.whl/pip/_internal/cli/main_parser.py", line 7, in
File "", line 259, in load_module
File "/tmp/tmp7_mor_ds/pip-19.2.3-py2.py3-none-any.whl/pip/_internal/cli/cmdoptions.py", line 15, in
ModuleNotFoundError: No module named 'distutils'然后尝试安装distutils:
trever@server:~$ sudo apt install python3.8-distutils
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
python3.8-lib2to3
The following NEW packages will be installed:
python3.8-distutils python3.8-lib2to3
0 upgraded, 2 newly installed, 0 to remove and 27 not upgraded.
Need to get 0 B/314 kB of archives.
After this operation, 1,235 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
(Reading database ... 194796 files and directories currently installed.)
Preparing to unpack .../python3.8-lib2to3_3.8.0-1+bionic2_all.deb ...
Unpacking python3.8-lib2to3 (3.8.0-1+bionic2) ...
dpkg: error processing archive /var/cache/apt/archives/python3.8-lib2to3_3.8.0-1+bionic2_all.deb (--unpack):
trying to overwrite '/usr/lib/python3.8/lib2to3/Grammar.txt', which is also in package python3-lib2to3 3.6.9-1~18.04
dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
Preparing to unpack .../python3.8-distutils_3.8.0-1+bionic2_all.deb ...
Unpacking python3.8-distutils (3.8.0-1+bionic2) ...
dpkg: error processing archive /var/cache/apt/archives/python3.8-distutils_3.8.0-1+bionic2_all.deb (--unpack):
trying to overwrite '/usr/lib/python3.8/distutils/README', which is also in package python3-distutils 3.6.9-1~18.04
dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
Errors were encountered while processing:
/var/cache/apt/archives/python3.8-lib2to3_3.8.0-1+bionic2_all.deb
/var/cache/apt/archives/python3.8-distutils_3.8.0-1+bionic2_all.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)我甚至不能让它全部移除/重新安装:
trever@server:/usr/lib/python3.8$ sudo apt --fix-broken install
Reading package lists... Done
Building dependency tree
Reading state information... Done
Correcting dependencies... Done
The following additional packages will be installed:
python
Suggested packages:
python-doc python-tk
The following NEW packages will be installed:
python
0 upgraded, 1 newly installed, 0 to remove and 27 not upgraded.
7 not fully installed or removed.
Need to get 0 B/140 kB of archives.
After this operation, 639 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Setting up python2.7-minimal (2.7.17-1~18.04) ...
Could not find platform independent libraries
Consider setting $PYTHONHOME to [:]
/usr/bin/python2.7: can't open file '/usr/lib/python2.7/py_compile.py': [Errno 2] No such file or directory
dpkg: error processing package python2.7-minimal (--configure):
installed python2.7-minimal package post-installation script subprocess returned error exit status 2
dpkg: dependency problems prevent configuration of python-minimal:
python-minimal depends on python2.7-minimal (>= 2.7.15~rc1-1~); however:
Package python2.7-minimal is not configured yet.
dpkg: error processing package python-minimal (--configure):
dependency problems - leaving unconfigured
Errors were encountered while processing:
python2.7-minimal
python-minimal
E: Sub-process /usr/bin/dpkg returned an error code (1)发布于 2020-03-05 07:55:48
rm -rf /usr/lib/python3.7/site-packages
python3.7 -m接踵而来
pip安装--升级pip
您需要删除pip包,而不是站点包中所有已安装的包。
发布于 2021-01-26 17:51:43
我的主目录中的python似乎被破坏了。
既然我有蟒蛇,
我只需使用命令将其从用户目录中删除:
rm -rf /home/myusername/.local/lib/python3.6/
然后在某些anaconda中运行pip将解析为anaconda中的pip。
https://askubuntu.com/questions/1214956
复制相似问题