Tuesday, May 14, 2024
 Popular · Latest · Hot · Upcoming
51
rated 0 times [  51] [ 0]  / answers: 1 / hits: 43750  / 1 Year ago, wed, january 4, 2023, 6:50:58

I updated python to python3.9, and when I try to install pip, I get an error:


lors@Lenovo:~$ pip3 install pipenv
Traceback (most recent call last):
File "/usr/bin/pip3", line 9, in <module>
from pip import main
File "/usr/lib/python3/dist-packages/pip/__init__.py", line 29, 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.9/distutils/__init__.py)

More From » python

 Answers
2

I am assuming you did changed update-alternatives for python3. What is happening that you have distutils installed in your last python version, but not in the new one! And because you've changed system link with "update-alternatives", system no longer finds it with the new link of python3. To fix this you have to install distutils to python3.9.


sudo apt install python3.9-distutils

And then you can test it with following line written in terminal:


python3 -c "from distutils import sysconfig"

If there is no Traceback you are good to go.


[#2359] Wednesday, January 4, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
itteast

Total Points: 291
Total Questions: 123
Total Answers: 104

Location: Tuvalu
Member since Wed, Mar 29, 2023
1 Year ago
itteast questions
;