gpt4 book ai didi

自系统更新以来 python3 pip 损坏

转载 作者:太空狗 更新时间:2023-10-30 00:58:39 26 4
gpt4 key购买 nike

在 AWS 上更新我的一台 Ubuntu 16.04 机器后,python/pip 似乎损坏了。

ubuntu@host:~$ pip install celery
Traceback (most recent call last):
File "/home/ubuntu/virtualenvs/myenv/bin/pip", line 7, in <module>
from pip import main
File "/home/ubuntu/virtualenvs/myenv/lib/python3.6/site-packages/pip/__init__.py", line 43, in <module>
from pip.utils import get_installed_distributions, get_prog
File "/home/ubuntu/virtualenvs/myenv/lib/python3.6/site-packages/pip/utils/__init__.py", line 23, in <module>
from pip.locations import (
File "/home/ubuntu/virtualenvs/myenv/lib/python3.6/site-packages/pip/locations.py", line 9, in <module>
from distutils import sysconfig
File "/home/ubuntu/virtualenvs/myenv/lib/python3.6/distutils/__init__.py", line 25, in <module>
from distutils import dist, sysconfig
ImportError: cannot import name 'dist'

ubuntu@host:~$ python3.6 -m pip install celery
Traceback (most recent call last):
File "/usr/lib/python3.6/runpy.py", line 183, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File "/usr/lib/python3.6/runpy.py", line 142, in _get_module_details
return _get_module_details(pkg_main_name, error)
File "/usr/lib/python3.6/runpy.py", line 109, in _get_module_details
__import__(pkg_name)
File "/home/ubuntu/virtualenvs/myenv/lib/python3.6/site-packages/pip/__init__.py", line 43, in <module>
from pip.utils import get_installed_distributions, get_prog
File "/home/ubuntu/virtualenvs/myenv/lib/python3.6/site-packages/pip/utils/__init__.py", line 23, in <module>
from pip.locations import (
File "/home/ubuntu/virtualenvs/myenv/lib/python3.6/site-packages/pip/locations.py", line 9, in <module>
from distutils import sysconfig
File "/home/ubuntu/virtualenvs/myenv/lib/python3.6/distutils/__init__.py", line 25, in <module>
from distutils import dist, sysconfig
ImportError: cannot import name 'dist'

系统运行通过jonathonf/python-3.6 ppa安装的python3.6。在系统更新(apt-get update && apt-get upgrade)之前,一切都按预期进行。我还在尚未更新的其他机器上验证了这一 pip 。

我也没有在新机器的虚拟环境中安装 python3.6,所以我猜最近的版本或更新在这里破坏了什么?


编辑:

我在新的 ubuntu 上安装时也遇到了类似的问题:

$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo add-apt-repository jonathonf/python-3.6
$ sudo apt-get update
$ sudo apt-get install python3.6

$ stat /usr/lib/python3.6/distutils/dist.py
stat: cannot stat '/usr/lib/python3.6/distutils/dist.py': No such file or directory

$ ll /usr/lib/python3.6/distutils/
total 36
drwxr-xr-x 2 root root 4096 May 3 15:55 ./
drwxr-xr-x 28 root root 12288 May 3 15:44 ../
-rw-r--r-- 1 root root 236 May 3 11:50 __init__.py
-rw-r--r-- 1 root root 12345 May 3 11:50 version.py

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.4 LTS
Release: 16.04
Codename: xenial

最佳答案

我在一个新的 docker 容器中测试了 PPA,看起来包坏了,所有 distutils 模块在安装后都丢失了。看起来这个包是最近重建的;也许这是一个新问题。

You can open a bug并等待 PPA 维护者修复它,但除此之外,您无能为力。您当然可以尝试摆弄安装:

$ wget https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tgz
$ tar xvf Python-3.6.5.tgz
$ rsync -av Python-3.6.5/Lib/distutils/ /usr/lib/python3.6/distutils/

当然,这是一个非常脏的东西,因为我不知道那个 PPA 的正确包应该有哪些文件。因此,我不能向您保证这是否对您有用并且不会引入任何新错误,但至少我可以再次运行 pip 并可以安装一个包。

关于自系统更新以来 python3 pip 损坏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50157653/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com