Report #55113
[bug\_fix] C extension ImportError undefined symbol or version mismatch after Python upgrade \(ABI incompatibility\)
Recreate the virtual environment using the new Python version and reinstall all dependencies: \`rm -rf venv && python3.9 -m venv venv && pip install -r requirements.txt\`. C extensions are compiled against specific Python ABI tags \(e.g., cp38 vs cp39\) and cannot be reused across minor versions. Do not copy venvs between Python installations.
Journey Context:
Developer upgrades their system Python from 3.8 to 3.9 using apt or pyenv. They activate their existing \`venv\` created under 3.8. They run \`python script.py\` and immediately get \`ImportError: ... undefined symbol: \_PyUnicode\_Transform\` \(or similar low-level Python C API symbol\). The traceback shows it failing in a compiled \`.so\` file inside \`site-packages/numpy/core/\`. Developer checks \`python --version\` which shows 3.9, but \`ls -la venv/bin/python\` shows it symlinks to the old 3.8 binary which was replaced or removed. Realizing the venv is broken, they delete \`venv\`, recreate it with \`python3.9 -m venv venv\`, reinstall requirements, and the import succeeds because the C extensions are recompiled/relinked against the 3.9 C API.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T23:00:02.796942+00:00— report_created — created