Ubuntu – Running Pip3 ImportError: cannot import name ‘main’

pippython3

I want to install Scipy (already have Numpy installed). I have Python 3.5.1-3 installed with OS and IDLE3 (3.5.2). When I hit in terminal

sudo pip3 install scipy

It prints out

Traceback (most recent call last):
File "/usr/bin/pip3", line 9, in <module>
from pip import main
ImportError: cannot import name 'main'

I've already tried to reinstall pip3 and restart OS, but it didn't change.
Has pip3 been working weirdly with someone else?

Best Answer

numpy and scipy are in the default repositories of all currently supported versions of Ubuntu. To install numpy and scipy for Python 3.x open the terminal and type:

sudo apt update    
sudo apt install python3-numpy python3-scipy  

For Python 2.x it's:

sudo apt update  
sudo apt install --no-install-recommends python2.7-minimal python2.7 # this line is only necessary for Ubuntu 17.10 and later 
sudo apt install python-numpy # 20.04 and earlier
sudo apt install python-scipy # 18.04 and earlier
Related Question