6

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

or:

from numpy import  *
ImportError: No module named 'numpy'
  • do you try sudo apt-get install python-matplotlib before sudo apt-get install python3-numpy?? – Nadimul De Cj 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 – ArcaneDominion Mar 22 '16 at 11:42
10

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
3

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

or

python3 --version
0

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.

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.