Developer Fix

VS Code Not Detecting Python Packages? Here’s the Fix

If VS Code says a Python package is missing even after installing it, the problem is usually the wrong interpreter, wrong environment, or package installed in a different Python version.

Difficulty: Easy–Medium Time: 10–20 minutes Updated: July 2026 Works for: Windows / Python

This is one of the most common Python problems in VS Code. You install a package, but VS Code still shows errors like ModuleNotFoundError or Import could not be resolved.

The package is usually installed — just not in the Python environment VS Code is using.

Fix 1 — Select the correct Python interpreter

  1. Open VS Code.
  2. Press Ctrl + Shift + P.
  3. Search for Python: Select Interpreter.
  4. Select the Python version where your package is installed.
  5. Restart VS Code.

This fixes the issue most of the time. VS Code can’t detect packages from an interpreter it isn’t using. Simple villain, big headache.

Fix 2 — Check which Python terminal is using

Open the VS Code terminal and run:

python --version

Then run:

where python

This shows which Python installation is active. If it points to a different location than expected, VS Code is using the wrong Python.

Fix 3 — Install the package in the active environment

Instead of installing randomly, use this command inside the VS Code terminal:

python -m pip install package-name

Example:

python -m pip install pandas

This makes sure the package installs into the Python environment currently being used.

Fix 4 — If using virtual environment

If your project uses a virtual environment, activate it first.

For Windows:

.venv\Scripts\activate

Then install the package:

python -m pip install pandas

Fix 5 — Restart the language server

Sometimes the package is installed correctly, but VS Code still shows a red underline. Restarting the Python language server can fix that.

  1. Press Ctrl + Shift + P.
  2. Search Python: Restart Language Server.
  3. Run it.
  4. If needed, restart VS Code.

Common reasons this happens

FAQ

Why does pip say installed but VS Code says missing?

Because pip may have installed the package in a different Python environment than the one VS Code is using.

Should I use virtual environments?

Yes. Virtual environments keep project packages clean and reduce version conflicts.

Will reinstalling VS Code fix this?

Usually no. The problem is normally Python environment selection, not VS Code itself.

VS Code & Python troubleshooting directory

Choose the symptom that most closely matches what you see: