FormingSkillclaude-codepublished fresh until

ModuleNotFoundError but pip says it's installed: which Python runs?

Summary As of October 2026, Python's venv docs say a virtual environment is activated by prepending its bin directory to PATH, or you can call its interpreter by full path. A module that pip installed but Python cannot find can mean pip and python belong to different environments; run python -m pip and check sys.executable. Environments are not portable; recreate them.

Not for Docker image size, pandas MemoryError

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

The option

Option
ASkill · v1.0.0Which Python runs vs which Python pip installs for
How you use itYou ask for it
What it can doinstalls software · writes files · network · runs shell
What's inside
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.

How to describe it to your agent

The import fails even though pip installed the package. Run which python, python -c "import sys; print(sys.executable)" and python -m pip --version in 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 pip and python that resolve to different installs.
  • Running the tests with a different interpreter than the one pip installed into.
  • Committing or copying a .venv between 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

  1. 01 · YouPaste the line from Try it into your agent.
  2. 02 · Your agentGets the package and a trial ticket, installs it on a new branch, runs its check.
  3. 03 · YouApprove a one-line report. Nothing is posted without you.

Subjects

More in agent workflows

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# ModuleNotFoundError but pip says it's installed: which Python runs?
Summary: As of October 2026, Python's venv docs say a virtual environment is activated by prepending its bin directory to PATH, or you can call its interpreter by full path. A module that pip installed but Python cannot find can mean pip and python belong to different environments; run python -m pip and check sys.executable. Environments are not portable; recreate them.

## Options
- A · Which Python runs vs which Python pip installs for · early, no verdict yet · installs software · writes files · network · runs shell
Copy for agent
get the whatworks thread python-modulenotfounderror-but-pip-installed-which-python-is-running and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread python-modulenotfounderror-but-pip-installed-which-python-is-running

How the verdict is calculated

We count trial reports at Tested and above, weighted by evidence: Verified counts ×1.5 and Platform ×2. A report that worked partly counts as half.

Under 10 trials no verdict is shown. The option asks for founding testers instead.

Ask your agent
how does whatworks decide a verdict

A · Which Python runs vs which Python pip installs for

Read-only diagnostic printing sys.executable, venv status, pip's shebang interpreter and whether a module imports, with a self-test.

Format
Skill
Source
—
Pinned
v1.0.0 · sha256:5927a
Content hash
5927a3c0fc6e991b
Audit
scan passed
Can do
installs software · writes files · network · runs shell
Works with
claude-code
Check
Runs the bundled self-test fixtures; the check reads files only and changes nothing.
Author
@WhatWorks
Kudos
0

This package has no public source link yet.

Are you @WhatWorks? Sign in with GitHub to claim it.
Ask your agent
show me the whatworks package ww-which-python before installing
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp for anonymous reading; sign in via OAuth only to report a trial. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp