12

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'
Kevin Bowen
  • 20,055
  • 57
  • 82
  • 84
rjbir
  • 123

4 Answers4

15

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
mchid
  • 44,904
  • 8
  • 102
  • 162
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

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

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.

mchid
  • 44,904
  • 8
  • 102
  • 162
cat
  • 1,712