Import "numpy" could not be resolved is a Pylance warning in VS Code. It means the Python interpreter VS Code is using doesn’t have NumPy installed. Select the right interpreter, or install NumPy into the one that’s selected:
Ctrl+Shift+P -> Python: Select Interpreter -> pick your .venv
python -m pip install numpy # run in the VS Code terminal
Pylance is built on Pyright, so I reproduced the exact message with the Pyright command-line tool and Python 3.12.5, then fixed it the same way you would in VS Code.
I’ll show why the warning appears, the two fixes for packages like NumPy, the fix for your own modules in another folder, and what to try when it still won’t go away.
Why does Pylance say import numpy could not be resolved?
Pylance looks for packages in the interpreter selected for your workspace. If NumPy is installed somewhere else, such as your global Python or a different venv, Pylance can’t see it:
import numpy as np
prices = np.array([19.99, 4.50, 102.00])
print(f"total: ${prices.sum():.2f}")
Output:
c:\pyguides\store_report.py
c:\pyguides\store_report.py:1:8 - error: Import "numpy" could not be resolved (reportMissingImports)
1 error, 0 warnings, 0 informations
Traceback (most recent call last):
File "C:\pyguides\store_report.py", line 1, in <module>
import numpy as np
ModuleNotFoundError: No module named 'numpy'

When the script also fails to run, the package really is missing from that environment. If it runs fine but Pylance still complains, VS Code is pointed at a different interpreter than the one in your terminal.
Fix 1: Select the right interpreter in VS Code
- Press Ctrl+Shift+P (Cmd+Shift+P on a Mac) and run Python: Select Interpreter.
- Pick the environment that has NumPy, usually
.venvin your project folder. - Check the interpreter shown in the bottom-right of the status bar.
- If the squiggle stays, run Developer: Reload Window.
Not sure which Python you’re using? python -c "import sys; print(sys.executable)" in the VS Code terminal tells you. For managing environments, see Python virtual environments.
Fix 2: Install NumPy into the selected interpreter
If the right interpreter is selected but NumPy isn’t in it, install it there. Using python -m pip from VS Code’s terminal guarantees the same environment:
uv pip install --python .venv-store\Scripts\python.exe numpy
pyright --pythonpath .venv-store\Scripts\python.exe store_report.py
.venv-store\Scripts\python.exe store_report.py
Output:
Using Python 3.11.17 environment at: .venv-store
Resolved 1 package in 20ms
Installed 1 package in 527ms
+ numpy==2.4.6
0 errors, 0 warnings, 0 informations
total: $126.49

There’s more on installing correctly in how to install a module in Python and ModuleNotFoundError after pip install.
Fixing could not be resolved for your own modules
The same warning appears for your own files in another folder, like shared/. Tell Pylance where to look with extraPaths; here it’s a pyrightconfig.json, which Pylance also reads:
from pricing import add_tax # pricing.py lives in the shared\ folder
print(f"${add_tax(100.00):.2f}")
Output:
c:\pyguides\checkout.py
c:\pyguides\checkout.py:1:6 - error: Import "pricing" could not be resolved (reportMissingImports)
1 error, 0 warnings, 0 informations
0 errors, 0 warnings, 0 informations

"extraPaths": ["shared"]: 0 errors.A folder named src is searched automatically, so it needs no setting.
In VS Code you can set the same thing as "python.analysis.extraPaths": ["shared"] in .vscode/settings.json. This only fixes the editor; to run the code, Python itself also needs to find the folder, as explained in Python import from another directory.
Still seeing could not be resolved in VS Code?
| Symptom | Try this |
|---|---|
| Code runs, Pylance still underlines | Select Interpreter again and reload the window |
| Yellow “reportMissingModuleSource” | Type stubs were found but the package isn’t installed; install it |
| Only in one folder of a multi-root workspace | Select the interpreter per folder |
| Package installed with conda | Pick the conda environment in Select Interpreter |
| Just started a new venv | Wait for Pylance to finish indexing, then reload |
If NumPy imports but crashes with a different message, see numpy.core.multiarray failed to import.
Related setup guides for VS Code and Python:
- PyCharm vs VS Code for Python
- How to run a Python script
- pip install -r requirements.txt
- Best AI for Python code
Frequently asked questions
Why does VS Code say import numpy could not be resolved?
Pylance is checking an interpreter that doesn’t have NumPy. Select the right interpreter, or install NumPy into the selected one.
My code runs but Pylance still shows the error. Why?
The terminal and VS Code are using different interpreters. Run Python: Select Interpreter and choose the one your terminal uses.
How do I fix could not be resolved for my own module?
Add the folder to python.analysis.extraPaths in VS Code settings, or to extraPaths in pyrightconfig.json.
Is reportMissingImports an error in my code?
No. It’s an editor warning about where packages are installed. Your code may still run if the right interpreter is used.
Can I just hide the warning?
You can add # type: ignore to the line, but fixing the interpreter is better since it also restores autocomplete.
Where are Pylance settings documented?
See Python settings reference in the VS Code docs.

Bijay Kumar is a 13-time Microsoft MVP with more than 18 years in software development, and the founder of Python Guides and TSinfo Technologies. He started out building .NET and SharePoint solutions at HP, TCS and KPIT before moving into Python, machine learning and AI, and he also builds web apps with TypeScript and React. He writes the tutorials here himself, and every example is run before publishing so you see the real output. More about Bijay · Microsoft MVP profile · LinkedIn