No module named 'numpy': Visual Studio Code

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 (mumpy come 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 pallete Ctrl+Shift+P in visual studio

check the link for how to switch from original python to anaconda python environment

You may not have numpy installed on the version of python you are running.

Try this:

import sys


Is the printed version Anaconda? 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.

The version of python that is called depends on which version of python comes up in your PATH variable first. Type into a terminal: echo $PATH. The output should look like this with Anaconda bin first: /Users/jlzhang/anaconda/bin:/usr/local/bin:/usr/bin:/bin

If you do not have Anaconda bin first, you can add this to your ~/.bashrc file: echo

# Use Anaconda python

export PATH="/Users/jlzhang/anaconda/bin:$PATH"

Restart a terminal and Visual Studio Code and see if you are now running Anaconda python.

Hope it helps/ Did it work?

We've found that simply changing the environment worked. Right-click on "Python Environments" and choose "Add/Remove Python Environments" and choose 3.5 instead of 3.6:

Add/Remove Python Environments