Python errors
Reproduced on pinned Python images, fixed and re-checked.
- ValueError: argument groups cannot be nested
ValueError: argument groups cannot be nested の直し方(Python 3.14 の argparse)
python@sha256:b877e50bd90de10af8d82c57a022fc2e0dc731c5320d762a27986facfc3355c1 · Creating an argument group from another argument group; deprecated since Python 3.11, Python 3.14 raises ValueError at definition timePython を 3.14 に上げたら、コマンドライン引数の定義で落ちます。
Python 4 min read - There is no current event loop in thread 'MainThread'
`RuntimeError: There is no current event loop in thread 'MainThread'` の直し方(Python 3.14 の asyncio)
python@sha256:b877e50bd90de10af8d82c57a022fc2e0dc731c5320d762a27986facfc3355c1 · asyncio.get_event_loop() called outside a running loop; the main-thread-only 'create one implicitly' special case warned in 3.12/3.13 and is gone in 3.14 (measured 3.11-3.14)asyncio.geteventloop() は、10 年以上「event loop が無ければ黙って作る」関数でした。Python 3.14 は、そのふるまいをやめました。
Python 7 min read - can't find Rust compiler
error: can't find Rust compiler の直し方(pip が wheel を使えずソースビルドに落ちるとき)
python:3.12.10-slim · cryptography 42.0.5 (Rust extension; no wheel -> source build) · pip source-builds a Rust-based package (--no-binary / no matching wheel) without rustcpip install(cryptography や pydantic、orjson など)の途中で、ビルドに入り、次のエラーで止まることがあります。
Python 7 min read - ModuleNotFoundError: No module named 'cgi'
ModuleNotFoundError: No module named 'cgi' の直し方(Python 3.13 が標準ライブラリから削除した)
python:3.13.14-slim · PEP 594 removed cgi (and crypt/telnetlib/imghdr/pipes/nntplib) from the stdlib in Python 3.13Python 3.12 まで動いていたコードを 3.13 で実行すると、次のエラーで落ちることがあります。
Python 8 min read - cannot import name 'Mapping' from 'collections'
ImportError: cannot import name 'Mapping' from 'collections' の直し方(Python 3.10 で collections 直下の ABC が削除された)
python:3.10-slim · CPython 3.10 (collections ABCs removed from top level) · from collections import Mapping (or other ABC) on Python 3.10+ (own code or an old third-party library)Python を 3.10 以降に上げてから、from collections import Mapping のようなインポートで次のエラーが出て止まることがあります。
Python 4 min read - configparser.InvalidWriteError: Cannot write key a=b; contains delimiter =
configparser.InvalidWriteError: Cannot write key ... contains delimiter の直し方(Python 3.14)
python@sha256:b877e50bd90de10af8d82c57a022fc2e0dc731c5320d762a27986facfc3355c1 · Writing a ConfigParser key that contains a default delimiter (= or :); Python 3.14 raises InvalidWriteError instead of emitting a file that reads back as a different keyPython を 3.14 に上げたら、設定ファイルの書き出しが落ちます。
Python 5 min read - No module named 'distutils'
ModuleNotFoundError: No module named 'distutils' の直し方(Python 3.12 で distutils が消えた)
python:3.12-slim · Python stdlib (distutils removed in 3.12 / PEP 632) · import distutils on Python 3.12+ without setuptools installedPython 3.11 までは動いていたスクリプトやツールが、3.12 に上げた環境で次のエラーで止まることがあります。
Python 5 min read - TypeError: unsupported operand type(s) for ** or pow(): 'int', 'Handler', 'int'
TypeError: takes 2 positional arguments but 3 were given の直し方(Python 3.14 でクラス属性の functools.partial が壊れる)
python@sha256:b877e50bd90de10af8d82c57a022fc2e0dc731c5320d762a27986facfc3355c1 · A functools.partial stored as a class attribute and called through an instance; Python 3.14 makes partial a method descriptor, so the instance is injected as the first positional argumentPython を 3.14 に上げたら、触っていないコードが次のエラーで落ちます。
Python 4 min read - No module named 'imghdr'
ModuleNotFoundError: No module named 'imghdr' の直し方(Python 3.13 で、自分が使っていない imghdr が依存ライブラリ経由で落ちる)
python:3.13.14-slim · CPython 3.13 (imghdr removed by PEP 594) x python-telegram-bot 13.15 · importing an old dependency (python-telegram-bot 13.15) that does 'import imghdr' internally, on Python 3.13 where imghdr is removedPython を 3.13 に上げてから、import telegram(python-telegram-bot)のようにライブラリを読み込むだけで次のエラーが出て止まることがあります。
Python 6 min read - Can't pickle <function <lambda>
`Can't pickle <function <lambda>>` の直し方(Python 3.14 で multiprocessing が落ちる)
python@sha256:b877e50bd90de10af8d82c57a022fc2e0dc731c5320d762a27986facfc3355c1 · Python 3.14 changes the default multiprocessing start method from fork to forkserver on the platforms where fork was the default (non-macOS POSIX: Linux, BSDs); measured on Linux: 3.12/3.13 = fork, 3.14 = forkserver. forkserver pickles the Process object by __qualname__, so a lambda target that fork used to copy through memory is now rejected in the parent at start()3.13 では通っていた Process(target=lambda: ...) が、3.14 では p.start() の行で——子プロセスが生まれる前に——落ちます。
Python 13 min read - module 'numpy' has no attribute 'float'
AttributeError: module 'numpy' has no attribute 'float' の直し方(numpy 1.24 で別名が削除された)
python:3.11-slim · numpy >=1.24 (np.float/np.int/np.object/np.str/np.complex aliases removed and still gone on 2.x; np.bool/np.long removed in 1.24–1.26 but revived in numpy 2.0) · using np.float/np.int/np.object/np.str/np.complex on numpy 1.24+ (np.bool/np.long only on 1.24–1.26; revived on 2.x); own code or an old third-party library; numpy pulled up by a dependencynumpy を新しくしてから、np.float を使っているところで次のエラーが出て止まることがあります。
Python 5 min read - A module that was compiled using NumPy 1.x cannot be run in
A module that was compiled using NumPy 1.x cannot be run in NumPy 2.x の直し方(numpy 2.0 で C 拡張が壊れる)
python:3.11-slim · numpy 2.0 (C-API ABI break) x numpy-1.x-built extensions (matplotlib/pandas) · numpy-1.x-compiled C extension imported under numpy 2.x (loose numpy upper bound lets pip install numpy 2)これまで動いていたスクリプトが、import matplotlib(や import pandas)の時点で次のエラーを出して止まることがあります。
Python 5 min read - json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Ollama で `think=false` を送ると `format`(JSON Schema)が無視される
ollama/ollama:0.31.1 · ollama /api/chat with think=false + format (JSON Schema) on a thinking model (qwen3.5:9b), CPUOllama の構造化出力は、format に JSON Schema を渡すとモデルの出力をその形に制約します。ところがサーバの版によっては、think=false を一緒に送った瞬間にこの制約が外れます。モデルはプロンプトどおりの自然文を返し、受け取った側の json.loads() が落ちる、という壊れ方です。
Ollama 8 min read - json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
OpenAI 互換 API(/v1)で Ollama に構造化出力を頼むと `reasoning_effort:"none"` のとき `response_format` が無視される
ollama/ollama:0.31.1 · ollama /v1 OpenAI-compat with response_format(json_schema) + reasoning_effort:none on a thinking model (qwen3.5:9b), CPUOpenAI の SDK をそのまま Ollama に向けて、responseformat に JSON Schema を渡し、モデルの出力を JSON に固定する。よくある使い方です。ところが reasoningeffort に "none" を添えた瞬間、返ってくるのが JSON ではなく英語の文章になり、受け取った側の json.loads() が落ちることがあります。
Ollama 6 min read - libGL.so.1: cannot open shared object file
ImportError: libGL.so.1 の直し方(opencv-python をサーバや Docker で import して落ちるとき)
python:3.12-slim · opencv-python (links GUI shared libs absent on headless Linux) · import cv2 from opencv-python on a headless/slim Linux missing libGL.so.1手元では動いていた OpenCV を使うコードが、Docker のイメージやサーバ、CI に載せた途端、import cv2 の行で次のエラーを出して止まることがあります。
Python 4 min read - ConvertPirAttribute2RuntimeAttribute not support [pir::ArrayAttribute<pir::DoubleAttribute>]
ConvertPirAttribute2RuntimeAttribute not support の直し方(PaddleOCR + paddlepaddle 3.3.1)
python:3.11 · PaddleOCR predict/ocr with paddlepaddle 3.3.1 (CPU, oneDNN enabled)PaddleOCR + paddlepaddle 3.3.1 の oneDNN 経路が出す ConvertPirAttribute2RuntimeAttribute(onednn_instruction.cc)。enable_mkldnn=False で oneDNN を切るか、回帰前の paddlepaddle 3.2.2 へ下げると解消します。
PaddleOCR 6 min read - No matching distribution found for paddlepaddle
No matching distribution found for paddlepaddle の直し方(Python 3.14 に wheel が無い)
python:3.14 · pip install paddlepaddle on Python 3.14 (no cp314 wheel on PyPI)新しく入れた Python で pip install paddlepaddle を実行すると、パッケージ名を打ち間違えたときと見分けの付かないエラーで止まることがあります。
PaddlePaddle 12 min read - module 'PIL.Image' has no attribute 'ANTIALIAS'
AttributeError: module 'PIL.Image' has no attribute 'ANTIALIAS' の直し方(Pillow 10 で削除された)
python:3.11-slim · Pillow >=10 (Image.ANTIALIAS removed; use Image.Resampling.LANCZOS) · using Image.ANTIALIAS on Pillow 10+ (own code, old tutorial, or a third-party library; Pillow pulled up by a dependency)Pillow を新しくしてから、画像のリサイズなどで Image.ANTIALIAS を使っているところで、次のエラーが出て止まることがあります。
Python 5 min read - externally-managed-environment
error: externally-managed-environment の直し方(Debian/Ubuntu で pip install が拒否される)
debian:12 · PEP 668 (EXTERNALLY-MANAGED marker on Debian/Ubuntu system Python) · pip install into system Python that carries the EXTERNALLY-MANAGED marker新しい Debian や Ubuntu で pip install を実行すると、パッケージを入れないまま次のエラーで止まることがあります。
Python 5 min read - No such file or directory: 'gcc'
error: command 'gcc' failed の直し方(wheel が無く pip がソースビルドに落ちるとき)
python:3.12-slim · any C-extension package without a matching wheel (psutil in verification) · pip falls back to source build (no wheel) on a slim image lacking gcc/python3-devpip install の途中で、パッケージのビルドに入り、次のエラーで止まることがあります。
Python 7 min read - ResolutionImpossible
ResolutionImpossible の直し方(pip install が依存の衝突で止まる)
python:3.12-slim · pip (new resolver, default since 20.3) · conflicting version pins (requests==2.25.0 requires urllib3<1.27, but urllib3==2.0.0 pinned)pip install が、パッケージを1つも入れないまま次のエラーで止まることがあります。
Python 5 min read - No module named 'pkg_resources'
ModuleNotFoundError: No module named 'pkg_resources' の直し方(setuptools が削除した)
python:3.12-slim · setuptools (removed pkg_resources in 82.0.0) · import pkg_resources with setuptools>=82 (removed) or without setuptoolsこれまで動いていたスクリプトやツールが、import pkg_resources の行で次のエラーを出して止まることがあります。
Python 4 min read - module 'pkgutil' has no attribute 'ImpImporter'
AttributeError: module 'pkgutil' has no attribute 'ImpImporter' の直し方(Python 3.12 と古い setuptools の食い違い)
python:3.12-slim · setuptools <66.1 (pkg_resources references removed pkgutil.ImpImporter) · importing pkg_resources on Python 3.12 with old setuptools (venv seed / pinned setuptools / old pip); fix window is setuptools 66.1..81Python 3.12 に上げてから、import pkgresources(あるいは pkgresources を使うツールの起動)で次のエラーが出て止まることがあります。
Python 5 min read - BaseSettings` has been moved to the `pydantic-settings` package
PydanticImportError: `BaseSettings` has been moved to the `pydantic-settings` package の直し方(Pydantic 2 で BaseSettings が別パッケージへ移った)
python:3.12.12-slim · Pydantic 2 (BaseSettings moved to the pydantic-settings package) · from pydantic import BaseSettings on Pydantic 2 (own code, or via a fresh FastAPI install that pulls Pydantic 2 but not pydantic-settings)設定クラスを読み込む from pydantic import BaseSettings の行で、次のエラーが出て止まることがあります。
Python 6 min read - invalid command 'test'
error: invalid command 'test' の直し方(setuptools 72 で python setup.py test が削除された)
python:3.13.14-slim · setuptools 72.0.0 (setup.py test command removed) · python setup.py test on setuptools 72+ where the test command was removed (typically a fresh CI env with a newer setuptools)CI やローカルで長く使ってきた python setup.py test が、ある日から次のエラーで止まることがあります。
Python 5 min read - setuptools-scm was unable to detect version
setuptools-scm was unable to detect version の直し方(.git の無い環境で pip がビルドできないとき)
python:3.12-slim · setuptools_scm 8 (dynamic version from SCM) · building a setuptools_scm package where .git is absent (GitHub ZIP / Docker COPY excluding .git via .dockerignore / git archive / vendored source)pip install(自作パッケージや、setuptools_scm を使うライブラリをソースから入れるとき)の途中で、ビルドに入り、次のエラーで止まることがあります。
Python 6 min read - is a named parameter, but you supplied a sequence
`sqlite3.ProgrammingError: Binding 1 (':value') is a named parameter` の直し方(Python 3.14)
python@sha256:b877e50bd90de10af8d82c57a022fc2e0dc731c5320d762a27986facfc3355c1 · named placeholder (:name / @name / $name — all three) bound with a non-dict sequence; DeprecationWarning in 3.12/3.13 (its text names 3.14) becomes sqlite3.ProgrammingError in 3.14. CPython rejects before sqlite3_bind_*, so the boundary is CPython, not SQLite (measured: sqlite3.sqlite_version is 3.46.1 on all four official python images)sqlite3.ProgrammingError という名前が付いていますが、この例外を投げているのは SQLite ではありません。
Python 8 min read - tarfile.OutsideDestinationError: '../escape' would be extracted to
tarfile.OutsideDestinationError: would be extracted to ... which is outside the destination の直し方(Python 3.14)
python@sha256:b877e50bd90de10af8d82c57a022fc2e0dc731c5320d762a27986facfc3355c1 · Extracting a tar member that escapes the destination (../ path or outward symlink); Python 3.14 defaults the extraction filter to 'data', which rejects it instead of writing outside the destinationPython を 3.14 に上げたら、これまで通っていた tar 展開が落ちます。
Python 5 min read - No module named 'telnetlib'
ModuleNotFoundError: No module named 'telnetlib' の直し方(Python 3.13 で、Netmiko など古い依存の import が telnetlib の削除で止まる)
python:3.13.14-slim · CPython 3.13 (telnetlib removed by PEP 594) x Netmiko 3.4.0 · importing an old dependency (Netmiko 3.4.0) that does 'import telnetlib' internally, on Python 3.13 where telnetlib is removedネットワーク自動化で使う Netmiko を Python 3.13 で読み込むと、import netmiko の時点で次のエラーが出て止まることがあります。
Python 5 min read - cannot import name 'url_quote' from 'werkzeug.urls'
ImportError: cannot import name 'url_quote' from 'werkzeug.urls' の直し方(Flask が新しい Werkzeug で落ちる)
python:3.11-slim · Flask 2.0.3 x Werkzeug 3.0 (url_quote removed) · loose Werkzeug>=2.0 constraint pulls Werkzeug 3.x; Flask 2.0.3 imports removed werkzeug.urls.url_quoteFlask のアプリを起動した瞬間、import flask の時点で次のエラーが出て止まることがあります。
Python 6 min read
条件に一致するエラーはありません。フィルタを緩めてください。