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

Here is the solution.

Reverse pip3 back to the previous version.

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

Install pip3 via python3.

$ python3 -m pip install pip

Use pip3 with python3 -m pip,

$ python3 -m pip 

For example,

$ python3 -m pip install -U scikit-image