I have to import numpy for a project in python, and I was told to simply install it in the CMD prompt, (pip install numpy). It says it is installed, but when I try to import it in python, it says: no module named 'numpy'. What did I do wrong or how do I fix this?
Asked
Active
Viewed 832 times
1
-
Try install with pip3 or running just with python Script.py – Frederick Feb 06 '21 at 13:46
-
can you explain in more detail, I'm not sure I understand? – Ube Van Grimbergen Feb 06 '21 at 13:48
-
when you use pip install package, you can "use" the package executing python your_script.py and the same is for pip3 and python3 – Frederick Feb 06 '21 at 13:50
-
okay thanks will try that – Ube Van Grimbergen Feb 06 '21 at 13:51
2 Answers
1
If you are using python version that is lower than 3 the method you tried should work so I am assuming you have a python version of 3.x.
For that you have to use
pip3 install numpy
As pip is for version lower than python 3 but pip3 is the one for python3.
EDIT
Since you said that it works in command prompt, so I believe that the pycharm is not using python3...?
If that’s the case try visiting here and set the appropriate version.
Hope it helps

Rajat Shenoi
- 590
- 2
- 7
- 22
-
idk if this helps, but it all works in the CMD prompt, but not in pycharm – Ube Van Grimbergen Feb 06 '21 at 15:10
-
1i found this site and it works now (https://www.simplilearn.com/tutorials/python-tutorial/pycharm#:~:text=To%20install%20NumPy%20on%20PyCharm,time%20that%20it%20executed%20successfully.) – Ube Van Grimbergen Feb 06 '21 at 15:26
0
Hi if you want to ensure you are using the python and pip in the same bin and the installation of numpy is also in the same bin, you can try:
$ python -m pip install numpy

hongkail
- 679
- 1
- 10
- 17
-
it still tells me no module named numpy when i try to import it – Ube Van Grimbergen Feb 06 '21 at 15:00
-
idk if this helps, but it all works in the CMD prompt, but not in pycharm – Ube Van Grimbergen Feb 06 '21 at 15:10
-
Read about you have resolved the issue from the pycharm settings. Congrats! – hongkail Feb 08 '21 at 01:33