'Python: Why does NumPy work executed from Command Line (Windows) but not from execution in IDLE?

I need to use NumPy and SciPy packages for Python.

However, for the longest time I could not find easy possibility to install just these packages alone - I had to install huge 3rd-party packages like Enthought, Anaconda, etc. that had collections of additional packages that I didn't want cluttering up my computer with limited memory...

I couldn't find another solution that worked with just simple installation (import) of NumPy and SciPy, so I installed Anaconda and was able to set up Environment called PYTHON352 for Python version that I use.

Then I installed successfully the NumPy and SciPy packages as per Conda instructions.

I was also able to install a plain vanilla version of NumPy directly into my Python34 and Python352 (Non-Anaconda Environment) as well as PYTHON352 (Anaconda3 Environment).

All of these have NumPy installed.

I take the following piece of code:

import numpy

data = numpy.array([[ 0.9526, -0.246 , -0.8856],
 [ 0.5639, 0.2379, 0.9104]])

print(data, type(data),len(data))

The problem/question is why does this work executed from the command line of the Anaconda3 only, but not from command line of the plain Python installations (3.4 and 3.5.2) or their IDLEs? Instead, when run from the IDLE, I get the following error message:

Traceback (most recent call last):
  File "C:\Anaconda3\envs\python352\numpy_test.py", line 1, in <module>
    import numpy
ImportError: No module named 'numpy'

Can anyone tell me why this is doing this and how to fix this? I really enjoy developing from my very simple IDLE and don't want to have to just hack through it by saving the file in the IDLE, and then going to command (CMD) line of the Anaconda installation (only!) in order to execute the Python file.

Thank you for your help.



Solution 1:[1]

Because anaconda prompt is different from the usual global OS command prompt unless synced or made the default.The packages are installed in anaconda which is different from the global command prompt.Your command prompt has to be set to use the build of python that is in your anaconda folder. Hope this helps

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ryukijano