- How you use it
- You ask for it
- What it can do
- installs software · writes files · network · runs shell
- What's inside
The option
| Option | ASkill · v1.0.0Which Python runs vs which Python pip installs for |
|---|---|
| How you use it | You ask for it |
| What it can do | installs software · writes files · network · runs shell |
| What's inside |
What this thread does
The problem
VS Code issue #201594 reports ModuleNotFoundError: No module named 'matplotlib' under Code Runner, while the Python run action succeeds. An import failure after installation can have several causes; first compare the interpreter running the program with the interpreter used by pip.
What the sources say
- Python's venv docs explain activation. Activation prepends the environment's bin directory to PATH and sets VIRTUAL_ENV. Activation is optional: call the interpreter by full path; installed scripts use its path in their shebang. Environments are "inherently non-portable": recreate rather than move them, and keep them out of git. Create the environment with python -m venv .venv, then restore dependencies with .venv/bin/python -m pip install -r requirements.txt. This requires a base Python with venv and an existing requirements.txt; see the pip guide. On POSIX:
python -m venv .venv
.venv/bin/python -m pip install -r requirements.txt
On Windows, invoke the environment's interpreter by its full path; activation is optional.
- Stack Overflow reports the symptom across causes: an editable install question and a "ModuleNotFoundError: No module named 'passlib'" despite installing question. These are individual reports, not a measured ranking.
How to describe it to your agent
The import fails even though pip installed the package. Runwhich python,python -c "import sys; print(sys.executable)"andpython -m pip --versionin the same command and compare them with the project's.venv. When this project uses an existing POSIX .venv, use its interpreter explicitly for installation and execution; on Windows use the environment's interpreter by its full path. Do not install packages globally.
Mistakes to check
- Using bare
pipandpythonthat resolve to different installs. - Running the tests with a different interpreter than the one pip installed into.
- Committing or copying a
.venvbetween machines instead of recreating it. - The editor or agent selecting a different interpreter than your terminal.
Limits
From Python docs and two Stack Overflow questions; I did not reproduce them.
Reports from users
- @vajranaga, 2023-12-28: "When I 'run Python file' everything is fine." — VS Code #201594. With matplotlib installed via pip and a venv loaded, Code Runner raised
ModuleNotFoundError, while the Python run action worked. The issue was closed as extension-related; it demonstrates differing launch paths, without proving which interpreter Code Runner selected.
Reports verified against the linked sources on 2026-10-28.
Primary source
Primary source: Python venv documentation (Python Software Foundation). Checked: activation prepends the environment's bin directory to PATH and sets VIRTUAL_ENV; activation is not required if you call the environment's interpreter by full path; scripts installed in the environment run without activation because their shebang points at its interpreter; environments are "inherently non-portable" (recreate rather than move) and are disposable and not checked into source control. The python -m pip / sys.executable diagnostic compares the running interpreter with pip; see the linked pip guide.
Started from a post by @Python docs and Stack Overflow questions, packaged by the editor. Original post
- 01 · YouPaste the line from Try it into your agent.
- 02 · Your agentGets the package and a trial ticket, installs it on a new branch, runs its check.
- 03 · YouApprove a one-line report. Nothing is posted without you.