No module named 'numpy': Visual Studio Code

select the appropriate version

click on python and select the appropriate version. your issue will be solved


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


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

Try this:

import sys

print(sys.version)

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?