Ubuntu 20.04 Python 3.10 pip import error

I've recently install python 3.10 in my ubuntu 20.04. My steps for installation were:

apt install python3.10
apt install python3.10-dev
apt install python3.10-distutils

Problem is about the pip. It crashes when I try to install anything with error:

ImportError: cannot import name 'html5lib' from 'pip._vendor' (/usr/lib/python3/dist-packages/pip/_vendor/__init__.py)

I have python versions 3.6 - 3.9 installed on my system. This problem only occurs with python version 3.10. What's the cause of this problem and solution?

3 Answers

I solved exactly the same symptoms by entering pipenv shell and installing pip there:

pipenv shell
curl -sS | python

This resulted in:

Collecting pip Using cached pip-21.3.1-py3-none-any.whl (1.7 MB)
Installing collected packages: pip Attempting uninstall: pip Found existing installation: pip 20.0.2 Uninstalling pip-20.0.2: Successfully uninstalled pip-20.0.2
Successfully installed pip-21.3.1

After that things started to work as expected and pipenv install was successful. Countless other ways of installing and reinstalling python/pip/pipenv failed, many times with the same import error.

2

The following commands solved my pip and sudo pip problems:

curl -sS | python 3.10
curl -sS | sudo python 3.10

You should better use pyenv and/or virtualenv. Some libs are not compatible with different python versions. Also pip does not know for what python version you want to install the requested lib.

Here are some tutorials or go and search in youtube.

2

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like