Post #1817634
2026-04-26 19:17 UTC
@sgillies I think its doing some dynamic wizardry...
>>> import PyQt5 as PQ
then this fails:
>>> PQ.QtCore.QUrl
Traceback (most recent call last):
File "", line 1, in
PQ.QtCore.QUrl
^^^^^^^^^
AttributeError: module 'PyQt5' has no attribute 'QtCore'
but if I import it from PyQt5.QtCore:
>>> from PyQt5.QtCore import QUrl
it then works...
>>> PQ.QtCore.QUrl
(and thats all in the same session)
Replies (1)
-
@sgillies@mastodon.social 2026-04-26 19:27
@geospacedman I peeked into the PyQt5 code. Indeed, there is no QtCore attribute in the top-level PyQt5 module. This means that you always have to `import PyQt5.QtCore` (or its sibling modules).