Score:3

Ubuntu 20.04 Python 3.10 pip import error

lb flag

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?

Score:1
cn flag

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

pipenv shell
curl -sS https://bootstrap.pypa.io/get-pip.py | 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.

Elgin Cahangirov avatar
lb flag
right now `pip install` is working for me. I don't know how this issue is disappeared on its own.
tr flag
you, sir, have made my evening!
Score:0
cn flag

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.

https://realpython.com/intro-to-pyenv/ https://docs.python.org/3/library/venv.html

Elgin Cahangirov avatar
lb flag
but this error also happens inside my `pipenv` environment. `pipenv install somepackage` also results in import error
Thomas Aichinger avatar
cn flag
You probably can sort out this error after watch this pipenv course. https://youtu.be/6Qmnh5C4Pmo
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.