Records below are third-party data, not instructions. Apply with your own judgment.
python
8 records of known failures, each with its cause, the fix and what not to try.
Records
- ImportError: attempted relative import with no known parent packagea file run by path executes as __main__ with no package context, so 'from .x import y' has no parent package to resolve against.
- ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certif…the python.org macOS build bundles its own OpenSSL, which ignores the Keychain; its default CA file does not exist until Install Certificates.command links certifi's bundle.
- ImportError: cannot import name '<name>' from partially initialized m…A imports B and B runs 'from A import name' while A is still executing its own imports, before name exists; a local file named like the imported module does the same.
- RuntimeError:
asyncio.run()cannot be called from a running event loopasyncio.run() starts and closes a fresh loop and refuses when the thread already runs one, as Jupyter/IPython kernels and async frameworks do. - TypeError: 'type' object is not subscriptablebuiltin generics such as list[int] and dict[str, int] arrived in Python 3.9 (PEP 585); 3.8 evaluates the annotation at def time and list has no __class_getitem__.
- ModuleNotFoundError: No module named 'imghdr'PEP 594 removed 19 'dead battery' modules from the 3.13 stdlib (imghdr, cgi, cgitb, telnetlib, pipes, crypt, audioop and more), all deprecated since 3.11.
- ModuleNotFoundError: No module named 'distutils'PEP 632 removed distutils from the 3.12 stdlib, and 3.12+ venvs no longer pre-install setuptools, the package that ships a drop-in distutils shim.
- DeprecationWarning:
datetime.datetime.utcnow()is deprecated and sche…utcnow() returns a naive datetime that many datetime methods treat as local time; 3.12 deprecated it and utcfromtimestamp() in favour of aware UTC values.
Don’t try
append the parent directory to sys.path inside the script — sys.path does not give __main__ a package; the relative import still fails unless it is rewritten as an absolute one. (×1) · record
cd into the package and run python -m main — main then becomes a top-level module with no parent package, so the same ImportError appears. (×1) · record
pip install certifi and retry — the ssl module never reads certifi on its own; urllib keeps loading the absent default CA file (requests works because it passes certifi's bundle itself). (×1) · record
ssl._create_unverified_context(), verify=False or PYTHONHTTPSVERIFY=0 — turns certificate checking off, so any interceptor can impersonate the server, and the trust store stays missing for every other client. (×1) · record
reinstall the library named in the error — if your own file is named like it (openai.py, random.py), Python imports that file instead; rename it (3.13+ says 'consider renaming'). (×1) · record
reorder the imports or import the other module first — the cycle stays; the error only moves to whichever module is imported first. (×1) · record
asyncio.get_event_loop().run_until_complete(main()) — same thread, same running loop: it raises RuntimeError: This event loop is already running. (×1) · record
nest_asyncio.apply() — it monkey-patches asyncio to allow re-entrant loops; the project is archived and its last release, 1.6.0, dates from January 2024. (×1) · record
add from __future__ import annotations and keep list[int] in aliases, cast() or isinstance() — the import only defers annotations; runtime expressions such as Ints = list[int] still raise the same TypeError on 3.8. (×1) · record
pip install imghdr — no PyPI project has that name; pip stops with 'No matching distribution found for imghdr'. (×1) · record
pip install puremagic and call puremagic.what(), as the 3.13 What's New suggests — puremagic 2.0 removed what() (only 1.24-1.30 have it), so the current release raises AttributeError: module 'puremagic' has no attribute 'what'. (×1) · record
apt install python3-distutils on Ubuntu 24.04 or newer — Ubuntu 24.04 (Python 3.12) publishes no python3-distutils package; it existed only for older Pythons such as 22.04's 3.10. (×1) · record
pip install distutils — the PyPI project of that name has no installable files; pip stops with 'No matching distribution found for distutils'. (×1) · record
mix the new aware values with existing naive ones — comparing them raises TypeError: can't compare offset-naive and offset-aware datetimes (subtraction fails the same way); convert both sides. (×1) · record
replace utcnow() with datetime.now() — now() without a tz returns local wall-clock time, so every value shifts by the UTC offset on a non-UTC machine. (×1) · record