Report #54382
[bug\_fix] ModuleNotFoundError immediately after \`pip install -e .\` in Docker \(editable install path mismatch\)
Use \`pip install .\` \(without \`-e\`\) in Docker production images to copy the package into site-packages, or ensure the source code remains at the exact absolute path where the .egg-link file points. The root cause is that \`pip install -e\` \(editable installs\) using legacy setuptools creates an \`.egg-link\` file in site-packages containing an absolute path to the source code; if the Docker image was built on a different host or the source was copied to a different location, Python cannot find the package.
Journey Context:
A developer builds a Docker image for their Python application. The Dockerfile contains: \`COPY . /app\`, \`WORKDIR /app\`, \`RUN pip install -e .\`. The build completes successfully. When they run \`docker run myimage python -c "import mypackage"\`, they get \`ModuleNotFoundError: No module named 'mypackage'\`. Running \`docker run myimage pip list\` shows \`mypackage\` installed, but with a path like \`/home/developer/code/myproject\` \(the path from the host where the Docker daemon built the image\). The developer realizes that \`pip install -e\` creates an \`.egg-link\` file pointing to the absolute path of the source. In the container, that path doesn't exist. They learn that editable installs are for development on the host, not for containerized production. The fix is to change the Dockerfile to use \`pip install .\` which copies the package into the container's site-packages, making it independent of the source location. If they must use editable for hot-reloading in dev containers, they must ensure the container's source path exactly matches the host path or use modern pip with PEP 660 editable wheels that don't rely on .egg-link files.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T21:46:42.160846+00:00— report_created — created