How to solve ImportError: cannot import name 'main'

less than 1 minute read

When I upgrade pip3 by typing sudo pip3 install -U pip and use the upgraded one, I get the error message ‘ImportError: cannot import name 'main'’. This is because a collision between pip3s installed by ubuntu and python3.

Here is the solution.

First, you need to reverse pip3 back to previous version.

$ python3 -m pip uninstall pip --user && sudo apt install python3-pip --reinstall

Second, install pip3 via python3.

$ python3 -m pip install pip

Then, whenever you want to use pip3, use it as,

$ python3 -m pip 

For example,

$ python3 -m pip install -U scikit-image