Improve import error when extension module is an incompatible build
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 77.2k
- Forks
- 35.9k
- PR-Merge-Kennzahlen
- PR-Kennzahlen ausstehend
Beschreibung
Feature or enhancement
Proposal:
Relatively regularly we get issues e.g. in NumPy because of incompatible extension module builds. (NumPy is often the first C-extension module someone loads.)
We have a long spammy message, but it includes the original error from Python:
Original error was: No module named 'numpy._core._multiarray_umath'
In this case, I had renamed the module to make it an incorrect build:
mv <snip>/lib/python3.11/site-packages/numpy/_core/_multiarray_umath.cpython-311-darwin.so <snip>/lib/python3.11/site-packages/numpy/_core/_multiarray_umath.cpython-312-darwin.so
I think it would be great if the error could include something like:
Binary module was build for a different Python version/system: Python version is cpython-312 rather than cpython-311) or (architecture x86 but expected arm64)
That way it is far more obvious that the build (or Python version) is wrong.
(Even just listing the files found and the expected file name would be good.)
I am not sure that is desirable for Python, since you would have to see if any file looks similar to the expected module when formatting the error. So in that case I may think about doing this in NumPy (since we know for a fact the file must be there somewhere).
Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Links to previous discussion of this feature:
I didn't find a discussion, this seems very slightly in a similar direction, but not about an incompatible build https://github.com/python/cpython/issues/69841.
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Der Issue nennt keine Quelldatei, keinen Test und keinen Einstiegspunkt. Bestimme zunächst, ob die Diagnose zu Pythons Importbehandlung von Erweiterungsmodulen oder zu NumPy gehört, und lege anschließend fest, wie inkompatible Dateinamen oder Architekturen erkannt werden sollen. Erledigt ist die Aufgabe, wenn eine inkompatible Erweiterung eine knappe, umsetzbare Meldung ausgibt, in der die relevanten erwarteten und gefundenen Build-Details angezeigt werden.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- backend
- Issue-Typ
- Feature
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100