0

升级到 ubuntu 焦点后,我丢失了 python3 dist 文件。比如math, subprocess, random,thread等等...我在旧的 ubuntu bionic 上安装了一个自编译的 python 3.8,我以异常方式删除了它(删除的目录位于/usr/local/lib/python3.8)。后来我使用sudo apt remove python3 && sudo apt install python3. 有什么办法可以找回这些包裹吗?ubuntu 焦点会发生常见错误吗?

我在旧仿生中编译 python 3.8 的方式

  • 从 python 站点下载的 zip 文件
  • 使用配置和安装./configure && make && sudo make install

尝试使用 pip 安装某些东西时出错

newtron@newtron:~$ sudo pip3 install pip --upgrade
Traceback (most recent call last):
  File "/usr/local/bin/pip3", line 5, in <module>
    from pip._internal.cli.main import main
  File "/usr/lib/python3/dist-packages/pip/_internal/cli/main.py", line 10, in <module>
    from pip._internal.cli.autocompletion import autocomplete
  File "/usr/lib/python3/dist-packages/pip/_internal/cli/autocompletion.py", line 9, in <module>
    from pip._internal.cli.main_parser import create_main_parser
  File "/usr/lib/python3/dist-packages/pip/_internal/cli/main_parser.py", line 7, in <module>
    from pip._internal.cli import cmdoptions
  File "/usr/lib/python3/dist-packages/pip/_internal/cli/cmdoptions.py", line 24, in <module>
    from pip._internal.exceptions import CommandError
  File "/usr/lib/python3/dist-packages/pip/_internal/exceptions.py", line 10, in <module>
    from pip._vendor.six import iteritems
ModuleNotFoundError: No module named 'pip._vendor.six'
Error in sys.excepthook:
Traceback (most recent call last):
  File "/usr/lib/python3.8/subprocess.py", line 64, in <module>
    import msvcrt
ModuleNotFoundError: No module named 'msvcrt'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in apport_excepthook
    from apport.fileutils import likely_packaged, get_recent_crashes
  File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in <module>
    from apport.report import Report
  File "/usr/lib/python3/dist-packages/apport/report.py", line 12, in <module>
    import subprocess, tempfile, os.path, re, pwd, grp, os, time, io
  File "/usr/lib/python3.8/subprocess.py", line 69, in <module>
    import _posixsubprocess
ModuleNotFoundError: No module named '_posixsubprocess'

Original exception was:
Traceback (most recent call last):
  File "/usr/local/bin/pip3", line 5, in <module>
    from pip._internal.cli.main import main
  File "/usr/lib/python3/dist-packages/pip/_internal/cli/main.py", line 10, in <module>
    from pip._internal.cli.autocompletion import autocomplete
  File "/usr/lib/python3/dist-packages/pip/_internal/cli/autocompletion.py", line 9, in <module>
    from pip._internal.cli.main_parser import create_main_parser
  File "/usr/lib/python3/dist-packages/pip/_internal/cli/main_parser.py", line 7, in <module>
    from pip._internal.cli import cmdoptions
  File "/usr/lib/python3/dist-packages/pip/_internal/cli/cmdoptions.py", line 24, in <module>
    from pip._internal.exceptions import CommandError
  File "/usr/lib/python3/dist-packages/pip/_internal/exceptions.py", line 10, in <module>
    from pip._vendor.six import iteritems
ModuleNotFoundError: No module named 'pip._vendor.six'
4

1 回答 1

1

您可以使用 pip 安装这些 python 包。如果您的 ubuntu 上没有 pip,请sudo apt install python3-pip 在终端中执行pip install 'missing package'

这些 python 包也没有丢失,但它们没有随 python3 一起提供。您必须使用 wheel 包或使用 pip 将它们安装到您的 python 环境中

编辑 您可以尝试运行此命令,看看它是否解决了您的问题:

curl -sS https://bootstrap.pypa.io/get-pip.py | sudo python3

似乎 manu Ubuntu 用户遇到了 pip3 和 python 的问题。似乎您不能将包与 gloabl python 一起使用,因为它会导致一些奇怪的问题,但您可以使用包和 pip3 只是在虚拟环境中找到。您还可以在这里找到更多信息和更好的答案:pip3 install not working - No module named 'pip._vendor.pkg_resources'

于 2020-05-01T08:01:36.947 回答