No module named 'numpy' (please read, not the common issue) #19590
-
Before answering, please read the issue completely. I have been searching all over the internet for an answer but only got an obvious answer to "pip3 install numpy" but it doesn't resolve the issue. so following is my issue : I have a main file "learning.ipynb" where I call different functions let's take for example "receptive_field.py". I have installed python3.6 in a virtual environment, which I selected as an interpreter. Now the problem is when I do run all for learning.ipynb it runs properly. But if I want to run receptive_field.py it shows the error No module named 'numpy'. The virtual environment is activated, numpy is installed,all files are in same folder still vscode shows such error. If I run the same code on pycharm separately I can very easily run the code without any errors(learning.ipynb and receptive_field.py both). Also if I run receptive_field.py in a separate terminal with pyhton3.6 virtual environment activated it runs without any error. It's only vscode giving error. Hope I get some answers here. In the figure, I have blacked out some parts of the code so it does not create any confusion and highlight the parts that I am facing issues with. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
I'm not sure how you are getting the command into the terminal, but you will notice you're running |
Beta Was this translation helpful? Give feedback.
-
Thank you for your answer. It seems we need to select the proper interpreter at two places. one at the top left corner of the main file and second at the right bottom corner. they might have different meanings which I am unaware of as of now. But things are running for me.. Thanks for your reply it really helped |
Beta Was this translation helpful? Give feedback.
I'm not sure how you are getting the command into the terminal, but you will notice you're running
/usr/local/bin/python3.8
in the terminal which is not a virtual environment and is Python 3.8, not Python 3.6 which means it doesn't match what you're using to run your Jupyter kernel.