I have python3.5.2 installed on a windows10 machine(Adding into the pythonpath is included in the setup with new python). I ,then, installed the Anaconda(4.2.0) version. At the command prompt when i run the python interpreter and import numpy it works fine. But when i save it as a script and try running from the IDLE, it gives
Traceback (most recent call last):
File "C:\Users\pramesh\Desktop\datascience code\test.py", line 1, in
from numpy import *
ImportError: No module named 'numpy'
I don't know what the problem is. I donot have any other python version installed.
解决方案
You do have two versions of python installed: the CPython 3.5.2 distribution you mention first, and the Anaconda 4.2.0 Python distribution you then mention. Anaconda packages a large number of 3rd party packages, including Numpy. However, the CPython 3.5.2 installation available on python.org only ships with the standard library.
These two python installs have separate package installations, so having Anaconda's numpy available doesn't make it available for the CPython install. Since you're starting the Idle with shipped with CPython, which doesn't have numpy, you're seeing this error. You have two options:
Install numpy for CPython. See numpy documentation for details on how to do this, but it may be difficult.
Use the version of Idle included with Anaconda. This should be available in the Anaconda programs folder.