由于“ImportError:无法从‘distutils’导入名称‘sysconfig’”而无法安装某些 Python 库

由于“ImportError:无法从‘distutils’导入名称‘sysconfig’”而无法安装某些 Python 库

我正在尝试将 Python 3.5 升级到 3.8.3,将 TensorFlow 1.13 升级到 2.2,以便能够保持最新状态。但是,我的计算机上有两个版本的 Python3 引起了一系列令人头痛的问题。(不过,我现在已将 python3 命令链接到 Python3.8!)

顺便说一句,我在 carykh 频道上制作有关编程的 YouTube 视频(有人告诉我这么说,这样我的问题就不会被忽视)。

今天早些时候,我可以安装tensorflow-gpu,但今天晚些时候,卸载后,由于标题和以下代码中的错误,我无法再次安装它。当我尝试安装 matplotlib 时,它会因相同的错误而失败。这很烦人,因为这些安装在 Python 3.5 上对我来说没有任何问题。有人能帮我弄清楚发生了什么吗?提前谢谢!

rob@robusic-land:/$ python3 -m pip install tensorflow-gpu
Traceback (most recent call last):
  File "/usr/lib/python3.8/runpy.py", line 185, in _run_module_as_main
    mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
  File "/usr/lib/python3.8/runpy.py", line 144, in _get_module_details
    return _get_module_details(pkg_main_name, error)
  File "/usr/lib/python3.8/runpy.py", line 111, in _get_module_details
    __import__(pkg_name)
  File "/usr/lib/python3/dist-packages/pip/__init__.py", line 14, in <module>
    from pip.utils import get_installed_distributions, get_prog
  File "/usr/lib/python3/dist-packages/pip/utils/__init__.py", line 23, in <module>
    from pip.locations import (
  File "/usr/lib/python3/dist-packages/pip/locations.py", line 9, in <module>
    from distutils import sysconfig
ImportError: cannot import name 'sysconfig' from 'distutils' (/usr/lib/python3.8/distutils/__init__.py)

我看到过类似的问题说尝试下面的安装,但它们本身导致了错误,或者没有导致任何行为的改变......

rob@robusic-land:/$ sudo apt-get install python-distutils
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package python-distutils
rob@robusic-land:/$ sudo apt-get install python3-distutils
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package python3-distutils
rob@robusic-land:/$ sudo apt-get install python-distutils-extra
Reading package lists... Done
Building dependency tree       
Reading state information... Done
python-distutils-extra is already the newest version (2.39-1).
0 upgraded, 0 newly installed, 0 to remove and 9 not upgraded.

相关内容