modalhub

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

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