Backend
VS Code Is Running the Wrong Python — Here's Why the Terminal and IntelliSense Disagree
SystemCraftDev Dev.to (EN Zone)
2 views
Your venv is activated and IntelliSense resolves everything, but the terminal runs a different Python. Here's why VS Code tracks two separate Pythons, and the real fix.
Adapted from the VS Code Essentials Companion Guide.
You created a virtual environment, activated it, installed your packages — and VS Code still can't find them. Or the opposite: IntelliSense recognizes everything perfectly, but running the file in the terminal throws ModuleNotFoundError for a package you know is installed. Either way, it feels like VS Code is lying to you about something as basic as which Python it's using.
It isn't lying. It's just tracking two separate things that happen to look like one.
What's actually happening
VS Code has two independent ideas of "your Python," and they don't automatically sync:
The selected interpreter is what the Python extension uses for IntelliSense, linting, and Go to Definition. It's set explicitly — via the Status Bar or the Python: Select Interpreter command — and it sticks until you change it, regardless of what else happens in your project.
The terminal's active environment is whatever shell state is in effect when a terminal panel opens — usually whichever python resolves to on your PATH at that moment, or whatever a venv's activation script last set.
These can drift apart easily. Selecting an interpreter in the Python extension doesn't retroactively fix terminals you already had open. Opening a new terminal after switching interpreters usually auto-activates the matching environment — but "usually" is doing a lot of work in that sentence, and older terminal panels never get updated at all. The result: IntelliSense and the terminal can each be confidently, independently wrong about which Python is "the" Python, and neither one will tell you the other disagrees.
The fix, step by step
Check what IntelliSense thinks first. Look at the Status Bar at the bottom of the window — it shows the currently selected interpreter (something like Python 3.11.4 ('venv': venv)). If this is wrong, run:
Python: Select Interpreter
and pick the correct one. This fixes IntelliSense, linting, and autocomplete — but not yet the terminal.
Check what the terminal thinks, separately. In an actual terminal panel, run:
which python # macOS/Linux
where python # Windows
Compare that path against the interpreter shown in the Status Bar. If they don't match, that's the whole problem — you have two different Pythons active in two different places.
Open a fresh terminal after fixing the interpreter. Close the old terminal panel and open a new one (Ctrl+Shift+`). A new terminal typically auto-activates the environment matching the currently selected interpreter — an already-open one will not retroactively update.
If the new terminal still doesn't auto-activate, activate the environment manually, the same way you would outside VS Code:
source venv/bin/activate # macOS/Linux
venv\Scripts\activate # Windows
Two mistakes worth knowing about ahead of time
Assuming "it works when I hover over the import" means the whole file will run correctly. IntelliSense resolving a package tells you the selected interpreter can see it — it says nothing about what a terminal's python file.py will use. These are genuinely separate checks, and passing one is not evidence for the other.
Installing a package a second time because "it's still not found." If pip install in a terminal reports success but the error persists, the terminal and the interpreter installing packages may not be the same Python. Check which python / where python before reinstalling anything — you may be about to install into an environment nothing is actually reading from.
A habit that prevents the confusion entirely
Whenever a project stops finding a package it should have, check both sides before touching anything: the Status Bar for what IntelliSense is using, and which python / where python in the terminal you're about to run code in. If those two don't match, you've found the entire bug already — no reinstalling, no deleting node_modules-style folders, no guessing. Open a new terminal, confirm it matches, and move on.
If you'd like more posts like this sent straight to your inbox, subscribe to the newsletter.
Prefer to dig in yourself? The VS Code Essentials repo on GitHub has more free examples and exercises.
Read original: https://dev.to/systemcraftdev/vs-code-is-running-the-wrong-python-heres-why-the-terminal-and-intellisense-disagree-75
← Previous
[For Hire] MERN Stack Developer — Open to small/low-budget projects
Next →
Google’s August 2026 Spam Update Is Complete: How Website Owners Should Respond
Related
Open-PR: một AI agent review PR nói chuyện như đồng nghiệp, không như một con bot
Backend
2
DEV Community
Was TinyStories the Domain or the Vocabulary?
Backend
2
DEV Community
Building an investing knowledge graph, part 6: if you're merging data from more than one source, you'll hit this
Backend
2
DEV Community
The Hard Truth About Data Engineering Interviews Nobody Tells You
Backend
2
DEV Community
Comments0
No comments yet — be the first