[英]ImportError: cannot import name 'sysconfig' from 'distutils' (/usr/lib/python3.8/distutils/__init__.py)
I installed pip3 using sudo apt-get install python3-pip
after that when I run the following command to install django sudo pip3 install django
I get this error:我使用sudo apt-get install python3-pip
安装了 pip3 之后,当我运行以下命令安装 django sudo pip3 install django
此错误:
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 14, in from pip.utils import get_installed_distributions, get_prog File "/usr/lib/python3/dist-packages/pip/utils/ init .py", line 23, in from pip.locations import ( File "/usr/lib/python3/dist-packages/pip/locations.py", line 9, in from distutils import sysconfig ImportError: cannot import name 'sysconfig' from 'distutils' (/usr/lib/python3.8/distutils/ init .py)回溯(最近一次调用):文件“/usr/bin/pip3”,第 9 行,从 pip import main 文件“/usr/lib/python3/dist-packages/pip/ init .py”,第 14 行,在from pip.utils import get_installed_distributions, get_prog File "/usr/lib/python3/dist-packages/pip/utils/ init .py", line 23, in from pip.locations import ( File "/usr/lib/python3/dist -packages / PIP / locations.py”,第9行,在从导入的distutils SYSCONFIG导入错误:无法导入名称从'的distutils'(/usr/lib/python3.8/distutils/ INIT的.py) 'SYSCONFIG'
How do I fix this?我该如何解决?
I have tried recently manually installing python3.9 version in my Ubuntu from 3.6 version using apt install python3.9
.我最近尝试使用apt install python3.9
从 3.6 版本在我的 Ubuntu 中手动安装 python3.9 版本。 Then pip3 was broken.然后pip3坏了。 The issue is because distutils were not build for the 3.9 version.问题是因为 distutils 不是为 3.9 版本构建的。
So in my case I ran apt install python3.9-distutils
to resolve my issue.所以就我而言,我运行apt install python3.9-distutils
来解决我的问题。
In your case make sure to modify 3.x version in distutils command.在您的情况下,请确保在 distutils 命令中修改 3.x 版本。
This helped but then I got another error: ImportError: No module named 'pip._internal'这有帮助,但后来我得到了另一个错误:ImportError: No module named 'pip._internal'
The following fixed it:以下修复了它:
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python3 get-pip.py --force-reinstall python3 get-pip.py --force-reinstall
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.