Report #10462
[bug\_fix] pkg\_resources.DistributionNotFound: The 'MyPackage' distribution was not found and is required by the application \(or importlib.metadata.PackageNotFoundError\)
Install the package in editable mode using pip install -e . from the directory containing setup.py or pyproject.toml, ensuring the package metadata is generated and available to pkg\_resources or importlib.metadata.
Journey Context:
Developer clones a repository containing a Python project with a setup.py defining entry points. They try to run the CLI script directly with python src/myapp/cli.py or the entry point script generated in bin/. They get DistributionNotFound. The code uses pkg\_resources.get\_distribution\('MyPackage'\).version or importlib.metadata.version\('MyPackage'\) to display the version, which requires the package's metadata to be present in the environment's site-packages or egg-info. Since the developer only cloned the repo without installing, the metadata is missing. They try pip install . which works but requires reinstall after every edit. The fix works because pip install -e . \(editable install\) creates an .egg-link file in site-packages pointing to the source and generates the .egg-info metadata directory, satisfying pkg\_resources without copying files, allowing development changes to be reflected immediately while providing the required metadata.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T10:46:19.259948+00:00— report_created — created