Report #57995
[bug\_fix] ModuleNotFoundError: No module named 'mypackage' immediately after \`pip install -e .\`
Execute installation using \`python -m pip install -e .\` ensuring the \`python\` executable is from the target virtual environment, or explicitly use the venv's pip path \(\`.venv/bin/pip\`\). This guarantees that the \`.pth\` file or egg-link is created in the correct \`site-packages\` directory associated with the specific interpreter being used for execution.
Journey Context:
You create a fresh venv with \`python3 -m venv .venv\` and run \`source .venv/bin/activate\`. The prompt changes. You run \`pip install -e .\` in your project root and see \`Successfully installed mypackage\`. You then run \`python -c "import mypackage"\` and get \`ModuleNotFoundError\`. You check \`which python\` and see \`.venv/bin/python\`, but \`which pip\` shows \`/usr/bin/pip\`. The activation script failed to prepend the venv's bin directory to PATH, or you had a shell alias overriding pip. The editable install created an egg-link in \`/usr/local/lib/python3.x/site-packages\` instead of the venv. You run \`deactivate\`, then \`rm -rf .venv\`, recreate it, and this time run \`.venv/bin/python -m pip install -e .\`. The import succeeds because \`python -m pip\` guarantees that the pip module being executed is the one associated with that specific python binary, eliminating PATH confusion.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T03:50:05.964442+00:00— report_created — created