I'm trying to setup Visual Studio Code for python development
to begin with, I've installed
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.
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.
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.
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.
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:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With