python / python/cpython

Add notes to `ImportError` for common issues

Open
#127,598 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

interpreter-core topic-importlib type-feature
Dominant language
Python
Stars
77.2k
Forks
35.9k
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
  • Failing to import a non-stdlib module with the site initialization disabled (-S)
  • Failing to import a module available in the user site-packages with the user site initialization disabled (-s)
  • Failing to import a module available in . with PYTHONSAFEPATH/-P enabled
  • Failing to import a module when ignoring PYTHON* environment variables (-E) but PYTHONPATH or PYTHONHOME are 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.