ImportError: No module named 'numpy' on Windows

I am new to the Python world. I need to run a code that uses matplotlib in python code. I am using Python 3.4 (32 bit) on Windows. I am using PyDev to develop and run a python script. I have installed matplotlib to

pip install matplotlib

      

When I tried to run the code again, it asks for "numpy"

Traceback (most recent call last):
File "D:\workspace\KMS\readpsds.py", line 14, in <module>
import matplotlib.pyplot as plt
File "C:\Python34\lib\site-packages\matplotlib\__init__.py", line 179, in <module>
from matplotlib.cbook import is_string_like
File "C:\Python34\lib\site-packages\matplotlib\cbook.py", line 32, in <module>
import numpy as np
ImportError: No module named 'numpy'

      

When I try to install numpy on

pip install numpy

      

it displays the following error on the command line

Command C:\Python34\python.exe -c "import setuptools, tokenize;__file__='C:\\Users\\Rsh\\AppData\\Local\\Temp\\pip_build_Rsh\\numpy\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record C:\Users\Rsh\AppData\Local\Temp\pip-t3a6a8l1-record\install-record.txt --single-version-externally-managed --compile failed with error code 1 in C:\Users\Rsh\AppData\Local\Temp\pip_build_Rsh\numpyStoring debug log for failure in C:\Users\Rsh\pip\pip.log

      

Please help me fix this. Thanks to

+3


source to share


3 answers


If you are thinking about using scientific packages on Windows (numpy, matplotlib), I recommend you use conda:

http://conda.io



It installs binaries so you won't see compiler errors anymore. Plus, you can always resort to pip if you need to.

+1


source


Install Anaconda and run python.exe in the directory where Anaconda is installed. If you are using sublime, you can create your system in this directory.

To build a build system, do the following: Tools -> Build System -> New Build System Then copy the following code in the window that opens and save it.



{
"cmd": ["YOUR_PATH_TO_ANACONDA/python.exe", "-u", "$file"],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.python"
}

      

Note that you must replace YOUR_PATH_TO_ANACONDA with your anaconda path.

+1


source


Try the following:

sudo apt-get install python3-numpy  

      

-2


source







All Articles