Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No module named 'numpy': Visual Studio Code

Tags:

I'm trying to setup Visual Studio Code for python development

to begin with, I've installed

  1. Anaconda Python
  2. Visual Studio Code

and in a new file I have the following code

import numpy as np import pandas as pd from pandas import Series, DataFrame 

upon hitting Ctrl+Shift+B I get the following error

import numpy as np 

ImportError: No module named 'numpy'

Also, is there python interactive window in VS Code? How to open it.

like image 743
billboard Avatar asked Oct 21 '16 21:10

billboard


People also ask

How do I fix No module named numpy?

The Python "ModuleNotFoundError: No module named 'numpy'" occurs when we forget to install the numpy module before importing it or install it in an incorrect environment. To solve the error, install the module by running the pip install numpy command.

How can I tell if numpy is installed in Vscode?

Go to Python -> site-packages folder. There you should be able to find numpy and the numpy distribution info folder. If any of the above is true then you installed numpy successfully.

Can we use numpy in VS code?

If you installed Anaconda python, it should come with numpy already installed. If it turns out to be another version of python you are accessing inside Visual Studio Code that doesn't have numpy installed, then that's what you need to fix.


1 Answers

Changing python environment in VS code helped me. Default the visual studio code takes original Python environment, it requires numpy to install. If you have anaconda python (numpy comes with it) installed, you could switch the original python environment to anaconda python environment in visuals studio code. This can be done from the command palette Ctrl+Shift+P in visual studio

Check this link for how to switch from original python to anaconda python environment, specifically:

Snippet from VSCode instructions enter image description here

like image 87
Madhukar Reddy Avatar answered Sep 28 '22 08:09

Madhukar Reddy