Report #104431
[bug\_fix] ModuleNotFoundError: No module named 'my\_module' after \`pip install --user my\_module\`
Avoid \`--user\` when using a virtual environment; instead, activate the venv and run \`pip install my\_module\`. If \`--user\` was used, ensure the user site-packages directory is in \`sys.path\` by running \`python -m site\` to verify, and consider adding \`export PYTHONPATH=$HOME/.local/lib/pythonX.Y/site-packages\` if needed.
Journey Context:
Developer installed a package with \`pip install --user my\_module\` while a virtual environment was active. They later deactivated the venv and tried to import the module in a system script, but got ModuleNotFoundError. They checked \`pip list\` and saw the package, but it was installed in the user site-packages directory, not the system site-packages. The root cause: \`--user\` forces installation into the user scheme, which may not be in \`sys.path\` for scripts run with \`sudo\` or in certain environments. The fix: they re-ran \`pip install my\_module\` without \`--user\` inside the venv, and the import worked.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-08-16T20:06:58.191402+00:00— report_created — created