ImportError: No module named 'numpy' in Windows
Solution 1
Install Anaconda, and run the python.exe in the directory in which Anaconda is installed. If you're using sublime, you can build your system in this directory.
To build a build system, do this: Tools -> Build System -> New Build System Then Copy the following code in the poped up window and save it.
{
"cmd": ["YOUR_PATH_TO_ANACONDA/python.exe", "-u", "$file"],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.python"
}
Notice that you should replace YOUR_PATH_TO_ANACONDA by your anaconda path.
Solution 2
If you are thinking of using scientific packages on Windows (numpy, matplotlib) I recommend you to use conda:
It installs binaries so you won't see any more compiler errors. Plus you can always resort to pip if you need to.
Related videos on Youtube
sagittarius
Updated on September 15, 2022Comments
-
sagittarius almost 2 years
I am a newbie in Python world. I have to run a code that uses matplotlib in the python code. I am using Python 3.4 (32 bit) in Windows. I use PyDev for development and running the python script. I installed matplotlib by
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 by
pip install numpy
it shows the following error in 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 to fix this. Thanks
-
Ffisegydd almost 10 yearsUse these Windows binaries to install numpy and matplotlib on Windows as opposed to using pip, it's easier that way.
-
sagittariusThank you :) It worked like a charm!!
-
-
sagittarius about 9 yearsIt was for Windows not Linux
-
Echo Liu about 9 years@sagittarius Oops sry I didn't notice the question was asking for Windows ;P