Actually I am shifting from Windows to Linux. Using pycharm on Windows I have a python 3 script that requires numpy and matplotlib to run, so I installed them on my Linux system using

sudo apt-get install python3-numpy
sudo apt-get install matplotlib3-numpy

But still when I try to run the script I get error:

from python3-numpy import  *
SyntaxError: invalid syntax


from numpy import  *
ImportError: No module named 'numpy'
  • do you try sudo apt-get install python-matplotlib before sudo apt-get install python3-numpy?? Mar 22 '16 at 11:27
  • yes @NadimulDeCj, retyping it says - "python-matplotlib is already the newest version."
    – rjbir
    Mar 22 '16 at 11:29
  • 2
    Are you sure you don't use python to run the file with "from numpy import *"? Many computers link python to Python 2.7 and python3 to Python 3 Mar 22 '16 at 11:42

You need to install numpy using pip
install pip :

sudo apt-get install python-pip python3-pip

Then install numpy using pip

sudo pip3 install -U numpy
  • from Ubuntu 20.04+ avoid installing python-pip as python3 is default with no python 2.x Aug 14 '20 at 21:19
  • This doesn't answer why? Shouldn't I be able to access system-installed packages assuming I'm not running in a virtual env or some other type of isolation tool?
    – Raman
    Nov 2 '20 at 22:08

Are you sure that you run python3 and not just python, which defaults to python2.7 on most systems.

You can get the Version of python with

python --version


python3 --version

If the other answer didn't work for you, try:

sudo apt-get update; sudo apt-get install python-pip python3-pip
sudo pip install numpy; sudo pip3 install numpy

If that doesn't work, then you have other issues.


same issue I faced. I installed and uninstalled numpy from terminal but didn't work for pycharm. I found that my issue was with the environment I created in Pycharm. Most likely package isn't installed.

just install it on your current env follow below steps. I'm using Mac and should be the same on other OS:

  1. go to preference
  2. under project, click on project interpreter
  3. then you'll see all packages you installed. if you don't see numpy, just click on the plus sign and search then install. it should work now

Good luck

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.