Add notes to `ImportError` for common issues
Open
Nobody has claimed this yet.
interpreter-core
topic-importlib
type-feature
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 36k
- PR merge metrics
- PR metrics pending
Description
Feature or enhancement
Proposal:
ImportErrors are very common, and almost always dependent on the interpreter initialization and/or environment setup. There are many common issues we could try to detect, and give users hints on the possible cause.
- Failing to load native modules when a module for a different ABI is available
- Eg. https://github.com/python/cpython/issues/127294#issuecomment-2501787837
- A
.cp313t-win_amd64.pydmodule is available, but we were looking for.cp313-win_amd64.pyd
- A
- Eg. https://github.com/python/cpython/issues/127294#issuecomment-2501787837
- Failing to import a non-stdlib module with the
siteinitialization disabled (-S) - Failing to import a module available in the user site-packages with the user
siteinitialization disabled (-s) - Failing to import a module available in
.withPYTHONSAFEPATH/-Penabled - Failing to import a module when ignoring
PYTHON*environment variables (-E) butPYTHONPATHorPYTHONHOMEare set (which users might be relying on) - (suggest more!)
Has this already been discussed elsewhere?
No response given
Links to previous discussion of this feature:
No response
Linked PRs
- gh-136817
- gh-136821
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No source files or tests are named in the issue. Review linked PRs gh-136817 and gh-136821 first, then trace the ImportError handling relevant to the selected environment cases; done means adding and testing helpful notes for the agreed cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- developer-experience
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100