0
votes

I want to import numpy. I do not have it as a module so I attempted to download it as a .whl file. I successfully downloaded it to my computer but am having trouble with installing into python 3.7.

I know I have to install numpy onto my computer and then Python. I downloaded the .whl file but am having trouble transferring it into my cmd prompt.

import numpy as np
Traceback (most recent call last):
File "stdin", line 1, in module
ModuleNotFoundError: No module named 'numpy'

I want to "import numpy as np" without errors

3
You should be using pip to install/manage your packages. - iz_
open a console, and type pip install numpy - warped
>>> pip install numpy File "<stdin>", line 1 pip install numpy ^ SyntaxError: invalid syntax - codextrmz

3 Answers

0
votes

The easiest way to download and manage modules is using python's built-in pip command.

pip install numpy will install numpy in your site-packages directory, where it needs to be to use it with Python 2

pip3 install numpy will do the same thing for Python 3

0
votes

try Anaconda home, it wil help you save a lot of time dealing with these errors. if u dont't want to use it, try

pip install numpy 

or

pip3 install numpy

like other answers.

0
votes

I've found that for python 3 on windows,

py -m pip install numpy 

works.

On Linux it's

python3 -m pip install numpy.

This would be entered into command prompt on windows, or terminal on Linux.

Furthermore, this will only work if you have python on your path. On windows you should be able to specify this when installing, on Linux it should be like this by default.

EDIT:

When installing, you should see this:

add python to path

You should check "add python to path" and click "Install now" since it will install pip for you

"pip"

I actually installed python without checking the "add python to path" and I can call it from CMD with py. So, if you can call it without the full path, then you are fine.

If you don't have pip....

Go to https://bootstrap.pypa.io/get-pip.py and either downloaded it, or copy and paste it into a python file. Run this file and pip should be installed. On windows you can also go to Control panel>Programs>Programs and Features and select python and click "Change". This should give you

install pip