Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

linux - PyQt5 error "PyCapsule_GetPointer called with incorrect name"

I've just built PyQt5 in a pyenv virtualenv with python 3.6.3 on OpenSUSE leap, the build went fine, but when I import

>>> from PyQt5 import QtCore
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: PyCapsule_GetPointer called with incorrect name

I can import PyQt5, but then I cannot use the modules under it

>>> import PyQt5
>>> PyQt5.QtCore
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'PyQt5' has no attribute 'QtCore'

I've read here that the cause could be another sip on the system for example of a PyQt4 installation, I tried to uninstall PyQt4 from the package manager but it didn't help.

I have no idea what to do, any ideas?

If I install the python3-qt5 package and use the system python it works

Edit:

I had the same problem with PyQt4 on another machine on OpenSUSE Leap 15, the solution was to configure sip with:

python configure.py --sip-module PyQt4.sip --no-dist-info --no-tools

as stated in the PyQt4 doc

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

OK so this was pretty easy actually, as stated in the doc (PyQt4, PyQt5), SIP must be configured with the --sip-module option, so for PyQt5 I did:

python configure.py --sip-module PyQt5.sip --no-tools

and for PyQt4:

python configure.py --sip-module PyQt4.sip --no-tools

This applies for PyQt >= 4.12.2 and PyQt >= 5.11

EDIT: PyQt5 now has the so called PyQt-builder, see the PyQt5 doc


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...