簡體   English   中英

導入時pyqt5分段錯誤

[英]pyqt5 segmentation fault on import

從 PyQt5 導入 Qt 會出現分段錯誤。

$ python
Python 2.7.12 (default, Nov 19 2016, 06:48:10) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from PyQt5 import Qt
[1]    7667 segmentation fault (core dumped)  python

使用 GDB 運行會提供更多信息。

$ gdb -ex r --args python -c "from PyQt5 import Qt"
...
Starting program: /usr/bin/python -c from\ PyQt5\ import\ Qt
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
strlen () at ../sysdeps/x86_64/strlen.S:106
106 ../sysdeps/x86_64/strlen.S: No such file or directory.

編輯:出於版本控制的原因,我不得不從源代碼編譯 PyQt5。 這是 PyQt 配置腳本的完整輸出 下面是縮略版。

$ python configure.py --verbose --qmake=/home/jeff/Qt/5.9.2/gcc_64/bin/qmake
Querying qmake about your Qt installation...
Determining the details of your Qt installation...
/home/jeff/Qt/5.9.2/gcc_64/bin/qmake -o cfgtest_QtCore.mk cfgtest_QtCore.pro
Info: creating stash file /home/jeff/Downloads/PyQt5_gpl-5.9/.qmake.stash
make -f cfgtest_QtCore.mk
g++ -c -pipe -O2 -std=gnu++11 -Wall -W -D_REENTRANT -fPIC -DQT_NO_DEBUG -DQT_CORE_LIB -I. -I../../Qt/5.9.2/gcc_64/include -I../../Qt/5.9.2/gcc_64/include/QtCore -I. -I../../Qt/5.9.2/gcc_64/mkspecs/linux-g++ -o cfgtest_QtCore.o config-tests/cfgtest_QtCore.cpp
g++ -Wl,-O1 -Wl,-rpath,/home/jeff/Qt/5.9.2/gcc_64/lib -o cfgtest_QtCore cfgtest_QtCore.o   -L/home/jeff/Qt/5.9.2/gcc_64/lib -lQt5Core -lpthread 
./cfgtest_QtCore cfgtest_QtCore.out
This is the GPL version of PyQt 5.9 (licensed under the GNU General Public
License) for Python 2.7.12 on linux2.

Type 'L' to view the license.
Type 'yes' to accept the terms of the license.
Type 'no' to decline the terms of the license.

Do you accept the terms of the license? yes
Found the license file pyqt-gpl.sip.

Checking to see if the QtGui module should be built...
/home/jeff/Qt/5.9.2/gcc_64/bin/qmake -o cfgtest_QtGui.mk cfgtest_QtGui.pro
make -f cfgtest_QtGui.mk
g++ -c -pipe -O2 -std=gnu++11 -Wall -W -D_REENTRANT -fPIC -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I. -I../../Qt/5.9.2/gcc_64/include -I../../Qt/5.9.2/gcc_64/include/QtGui -I../../Qt/5.9.2/gcc_64/include/QtCore -I. -isystem /usr/include/libdrm -I../../Qt/5.9.2/gcc_64/mkspecs/linux-g++ -o cfgtest_QtGui.o config-tests/cfgtest_QtGui.cpp
g++ -Wl,-O1 -Wl,-rpath,/home/jeff/Qt/5.9.2/gcc_64/lib -o cfgtest_QtGui cfgtest_QtGui.o   -L/home/jeff/Qt/5.9.2/gcc_64/lib -lQt5Gui -lQt5Core -lGL -lpthread 
./cfgtest_QtGui cfgtest_QtGui.out

...

Checking to see if the QtWebKit module should be built...
/home/jeff/Qt/5.9.2/gcc_64/bin/qmake -o cfgtest_QtWebKit.mk cfgtest_QtWebKit.pro
Project ERROR: Unknown module(s) in QT: webkit

Checking to see if the QtWebKitWidgets module should be built...
/home/jeff/Qt/5.9.2/gcc_64/bin/qmake -o cfgtest_QtWebKitWidgets.mk cfgtest_QtWebKitWidgets.pro
Project ERROR: Unknown module(s) in QT: webkitwidgets

...

Checking to see if the QAxContainer module should be built...
/home/jeff/Qt/5.9.2/gcc_64/bin/qmake -o cfgtest_QAxContainer.mk cfgtest_QAxContainer.pro
Project ERROR: Unknown module(s) in QT: axcontainer

...

Checking to see if the QtMacExtras module should be built...
/home/jeff/Qt/5.9.2/gcc_64/bin/qmake -o cfgtest_QtMacExtras.mk cfgtest_QtMacExtras.pro
Project ERROR: Unknown module(s) in QT: macextras

...

Checking to see if the QtWinExtras module should be built...
/home/jeff/Qt/5.9.2/gcc_64/bin/qmake -o cfgtest_QtWinExtras.mk cfgtest_QtWinExtras.pro
Project ERROR: Unknown module(s) in QT: winextras

...

Checking to see if the Enginio module should be built...
/home/jeff/Qt/5.9.2/gcc_64/bin/qmake -o cfgtest_Enginio.mk cfgtest_Enginio.pro
Project ERROR: Unknown module(s) in QT: enginio

...

Checking to see if the QtWebEngine module should be built...
/home/jeff/Qt/5.9.2/gcc_64/bin/qmake -o cfgtest_QtWebEngine.mk cfgtest_QtWebEngine.pro
make -f cfgtest_QtWebEngine.mk
g++ -c -pipe -O2 -std=gnu++11 -Wall -W -D_REENTRANT -fPIC -DQT_NO_DEBUG -DQT_WEBENGINE_LIB -DQT_WEBENGINECORE_LIB -DQT_QUICK_LIB -DQT_GUI_LIB -DQT_WEBCHANNEL_LIB -DQT_QML_LIB -DQT_NETWORK_LIB -DQT_POSITIONING_LIB -DQT_CORE_LIB -I. -I../../Qt/5.9.2/gcc_64/include -I../../Qt/5.9.2/gcc_64/include/QtWebEngine -I../../Qt/5.9.2/gcc_64/include/QtWebEngineCore -I../../Qt/5.9.2/gcc_64/include/QtQuick -I../../Qt/5.9.2/gcc_64/include/QtGui -I../../Qt/5.9.2/gcc_64/include/QtWebChannel -I../../Qt/5.9.2/gcc_64/include/QtQml -I../../Qt/5.9.2/gcc_64/include/QtNetwork -I../../Qt/5.9.2/gcc_64/include/QtPositioning -I../../Qt/5.9.2/gcc_64/include/QtCore -I. -isystem /usr/include/libdrm -I../../Qt/5.9.2/gcc_64/mkspecs/linux-g++ -o cfgtest_QtWebEngine.o cfgtest_QtWebEngine.cpp
cfgtest_QtWebEngine.cpp: In function ‘int main(int, char**)’:
cfgtest_QtWebEngine.cpp:5:17: warning: unused variable ‘v’ [-Wunused-variable]
    const char *v = QTWEBENGINE_VERSION_STR;
                ^
g++ -Wl,-O1 -Wl,-rpath,/home/jeff/Qt/5.9.2/gcc_64/lib -Wl,-rpath-link,/home/jeff/Qt/5.9.2/gcc_64/lib -o cfgtest_QtWebEngine cfgtest_QtWebEngine.o   -L/home/jeff/Qt/5.9.2/gcc_64/lib -lQt5WebEngine -lQt5WebEngineCore -lQt5Quick -lQt5Gui -lQt5WebChannel -lQt5Qml -lQt5Network -lQt5Positioning -lQt5Core -lGL -lpthread 
Checking to see if the dbus support module should be built...
pkg-config --cflags-only-I --libs dbus-1
Qt v5.9.2 is being used.
The qmake executable is /home/jeff/Qt/5.9.2/gcc_64/bin/qmake.
Qt is built as a shared library.
SIP 4.19.3 is being used.
The sip executable is /usr/bin/sip.
These PyQt5 modules will be built: QtCore, QtGui, QtHelp, QtMultimedia,
QtMultimediaWidgets, QtNetwork, QtOpenGL, QtPrintSupport, QtQml, QtQuick,
QtSql, QtSvg, QtTest, QtWidgets, QtXml, QtXmlPatterns, QtDesigner, QtDBus,
_QOpenGLFunctions_2_0, _QOpenGLFunctions_2_1, _QOpenGLFunctions_4_1_Core,
QtSensors, QtSerialPort, QtX11Extras, QtBluetooth, QtPositioning,
QtQuickWidgets, QtWebSockets, QtWebChannel, QtWebEngineWidgets, QtLocation,
QtNfc, QtWebEngineCore, QtWebEngine.
The PyQt5 Python package will be installed in /usr/lib/python2.7/dist-packages.
PyQt5 is being built with generated docstrings.
PyQt5 is being built with 'protected' redefined as 'public'.
The Designer plugin will be installed in
/home/jeff/Qt/5.9.2/gcc_64/plugins/designer.
The qmlscene plugin will be installed in
/home/jeff/Qt/5.9.2/gcc_64/plugins/PyQt5.
The dbus support module will be installed in
/usr/local/lib/python2.7/dist-packages/dbus/mainloop.
The PyQt5 .sip files will be installed in /usr/share/sip/PyQt5.
pyuic5, pyrcc5 and pylupdate5 will be installed in /usr/bin.
The interpreter used by pyuic5 is /usr/bin/python.
Generating the C++ source for the QtCore module...
/usr/bin/sip -w -f -x VendorID -t WS_X11 -t Qt_5_9_2 -x Py_v3 -B Qt_6_0_0 -P -o -c /home/jeff/Downloads/PyQt5_gpl-5.9/QtCore -I sip -I /home/jeff/Downloads/PyQt5_gpl-5.9/sip /home/jeff/Downloads/PyQt5_gpl-5.9/sip/QtCore/QtCoremod.sip
Embedding sip flags...

Generating the .pro file for the QtCore module...
Generating the C++ source for the QtGui module...
/usr/bin/sip -w -f -x VendorID -t WS_X11 -t Qt_5_9_2 -x Py_v3 -B Qt_6_0_0 -P -o -c /home/jeff/Downloads/PyQt5_gpl-5.9/QtGui -I sip -I /home/jeff/Downloads/PyQt5_gpl-5.9/sip /home/jeff/Downloads/PyQt5_gpl-5.9/sip/QtGui/QtGuimod.sip

...

Generating the .pro file for the pyrcc module...
Generating the C++ source for the Qt module...
/usr/bin/sip -w -f -x VendorID -t WS_X11 -t Qt_5_9_2 -x Py_v3 -B Qt_6_0_0 -P -c /home/jeff/Downloads/PyQt5_gpl-5.9/Qt -I sip -I /home/jeff/Downloads/PyQt5_gpl-5.9/sip sip/Qt/Qtmod.sip

Generating the .pro file for the Qt module...
Generating the pylupdate5 wrapper...
Generating the pyrcc5 wrapper...
Generating the pyuic5 wrapper...
Generating the Qt Designer plugin .pro file...
Generating the qmlscene plugin .pro file...
Re-writing
/home/jeff/Downloads/PyQt5_gpl-5.9/examples/quick/tutorials/extending/chapter6-plugins/Charts/qmldir...

Generating the .pro file for the dbus module...
Generating the top-level .pro file...
Making the pylupdate5 wrapper executable...
Making the pyrcc5 wrapper executable...
Making the pyuic5 wrapper executable...
Generating the Makefiles...
/home/jeff/Qt/5.9.2/gcc_64/bin/qmake -recursive PyQt5.pro
Reading /home/jeff/Downloads/PyQt5_gpl-5.9/QtCore/QtCore.pro
Reading /home/jeff/Downloads/PyQt5_gpl-5.9/QtGui/QtGui.pro
Reading /home/jeff/Downloads/PyQt5_gpl-5.9/QtHelp/QtHelp.pro
Reading /home/jeff/Downloads/PyQt5_gpl-5.9/QtMultimedia/QtMultimedia.pro
Reading /home/jeff/Downloads/PyQt5_gpl-5.9/QtMultimediaWidgets/QtMultimediaWidgets.pro
Reading /home/jeff/Downloads/PyQt5_gpl-5.9/QtNetwork/QtNetwork.pro
Reading /home/jeff/Downloads/PyQt5_gpl-5.9/QtOpenGL/QtOpenGL.pro
Reading /home/jeff/Downloads/PyQt5_gpl-5.9/QtPrintSupport/QtPrintSupport.pro
Reading /home/jeff/Downloads/PyQt5_gpl-5.9/QtQml/QtQml.pro
Reading /home/jeff/Downloads/PyQt5_gpl-5.9/QtQuick/QtQuick.pro
Reading /home/jeff/Downloads/PyQt5_gpl-5.9/QtSql/QtSql.pro
Reading /home/jeff/Downloads/PyQt5_gpl-5.9/QtSvg/QtSvg.pro
Reading /home/jeff/Downloads/PyQt5_gpl-5.9/QtTest/QtTest.pro
Reading /home/jeff/Downloads/PyQt5_gpl-5.9/QtWidgets/QtWidgets.pro
Reading /home/jeff/Downloads/PyQt5_gpl-5.9/QtXml/QtXml.pro
Reading /home/jeff/Downloads/PyQt5_gpl-5.9/QtXmlPatterns/QtXmlPatterns.pro
Reading /home/jeff/Downloads/PyQt5_gpl-5.9/QtDesigner/QtDesigner.pro
Reading /home/jeff/Downloads/PyQt5_gpl-5.9/QtDBus/QtDBus.pro
Reading /home/jeff/Downloads/PyQt5_gpl-5.9/_QOpenGLFunctions_2_0/_QOpenGLFunctions_2_0.pro
Reading /home/jeff/Downloads/PyQt5_gpl-5.9/_QOpenGLFunctions_2_1/_QOpenGLFunctions_2_1.pro
Reading /home/jeff/Downloads/PyQt5_gpl-5.9/_QOpenGLFunctions_4_1_Core/_QOpenGLFunctions_4_1_Core.pro
Reading /home/jeff/Downloads/PyQt5_gpl-5.9/QtSensors/QtSensors.pro
Reading /home/jeff/Downloads/PyQt5_gpl-5.9/QtSerialPort/QtSerialPort.pro
Reading /home/jeff/Downloads/PyQt5_gpl-5.9/QtX11Extras/QtX11Extras.pro
Reading /home/jeff/Downloads/PyQt5_gpl-5.9/QtBluetooth/QtBluetooth.pro
Reading /home/jeff/Downloads/PyQt5_gpl-5.9/QtPositioning/QtPositioning.pro
Reading /home/jeff/Downloads/PyQt5_gpl-5.9/QtQuickWidgets/QtQuickWidgets.pro
Reading /home/jeff/Downloads/PyQt5_gpl-5.9/QtWebSockets/QtWebSockets.pro
Reading /home/jeff/Downloads/PyQt5_gpl-5.9/QtWebChannel/QtWebChannel.pro
Reading /home/jeff/Downloads/PyQt5_gpl-5.9/QtWebEngineWidgets/QtWebEngineWidgets.pro
Reading /home/jeff/Downloads/PyQt5_gpl-5.9/QtLocation/QtLocation.pro
Reading /home/jeff/Downloads/PyQt5_gpl-5.9/QtNfc/QtNfc.pro
Reading /home/jeff/Downloads/PyQt5_gpl-5.9/QtWebEngineCore/QtWebEngineCore.pro
Reading /home/jeff/Downloads/PyQt5_gpl-5.9/QtWebEngine/QtWebEngine.pro
Reading /home/jeff/Downloads/PyQt5_gpl-5.9/pylupdate/pylupdate.pro
Reading /home/jeff/Downloads/PyQt5_gpl-5.9/pyrcc/pyrcc.pro
Reading /home/jeff/Downloads/PyQt5_gpl-5.9/Qt/Qt.pro
Reading /home/jeff/Downloads/PyQt5_gpl-5.9/designer/designer.pro
Reading /home/jeff/Downloads/PyQt5_gpl-5.9/qmlscene/qmlscene.pro
Reading /home/jeff/Downloads/PyQt5_gpl-5.9/dbus/dbus.pro

PyQt 應該忽略它不能識別所有 Qt 5.x 版本兼容性的 Qt 模塊,因此“未知模塊”位不太重要。

我正在使用:

  • Ubuntu 16.04
  • 蟒蛇 2.7.12
  • Qt 5.9.2
  • SIP 4.19.3(從源代碼編譯)
  • PyQt 5.9(從源代碼編譯)

舊版本的 SIP 存在於機器上並且正在被導入,而不是從源代碼構建的用於構建 PyQt 的新版本。 刪除舊版本的 SIP 可以解決此問題。

$ python
>>> import sip
>>> print sip.SIP_VERSION_STR
4.17

sudo apt remove python-sip舊版本后

$ python
>>> import sip
>>> print sip.SIP_VERSION_STR
4.19.3
>>> from PyQt5 import Qt    # Does not segfault

我在不同的設置(Slackware)上遇到了同樣的問題,這導致 Openshot 在啟動時無聲無息地崩潰。

原因是升級安裝了來自不同來源(松弛和外星人)的軟件包。

搜索以“qt5”和“Qt5”命名的包使我能夠識別錯誤的包並將其替換為相關版本,從而解決了問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM