PyQt5安装后,导入PyQt4模块会出现Segmentation Fault

时间:2018-04-25 06:48:02

标签: python segmentation-fault pyqt4

我在操作系统Linux Mint 18中使用python 3.5.2(64位),内核版本为4.4.0-109-generic。

很久以前我通过sudo apt-get install python3-pyqt4安装了PyQt4,一切都运行得很好,直到我最近通过pip PyQt5安装。

从那时起,我就可以import PyQt4import PyQt4.pyqtconfig而不是像import PyQt4.QtCoreimport PyQt4.QtGuiimport PyQt4.Qt那样退出python的模块有'分段错误'。我也意识到命令(在python环境中)help('modules')在几秒钟后给出相同的输出。

我试图用pip删除PyQt5并从终端重新安装PyQt4(版本4.11.4 + dfsg-1build4),但似乎没有任何改变。我也可以从/usr/lib/python3/dist-packages/PyQt4

看到PyQt4中的目录

我还试图在文件夹中创建一个带有virtualenv env --python=python3.5的python虚拟环境,并将整个目录从PyQt4复制到环境的dist-packages中,并在其中安装sip 。使用pip。{/ p>中的sip 4.19.8版本

我尝试的另一件事是使用gdb python3来运行只包含代码的python程序:

#!/usr/bin/python3
import PyQt4.QtCore

它返回的是:

$ gdb -q python3
Reading symbols from python3...Reading symbols from /usr/lib/debug/.build-id/59/a8ef36ca241df24686952480966d7bc0d7c6ea.debug...done.
done.
(gdb) run FaultPy35.py 
Starting program: /usr/bin/python3 FaultPy35.py
[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.
PyType_IsSubtype () at ../Objects/typeobject.c:1343
1343    ../Objects/typeobject.c: No such file or directory.
(gdb) c
Continuing.

Program terminated with signal SIGSEGV, Segmentation fault.
The program no longer exists.
(gdb) 

我对gdb很新,但显然问题超出了python包...

注意:我已通过dpkg-query -L python3-pyqt4检查了以下列表中已安装的软件包python3-pyqt4

/.
/usr
/usr/share
/usr/share/doc
/usr/share/doc/python3-pyqt4
/usr/share/doc/python3-pyqt4/THANKS
/usr/share/doc/python3-pyqt4/copyright
/usr/share/doc/python3-pyqt4/changelog.Debian.gz
/usr/lib
/usr/lib/python3
/usr/lib/python3/dist-packages
/usr/lib/python3/dist-packages/PyQt4
/usr/lib/python3/dist-packages/PyQt4/QtHelp.cpython-35m-x86_64-linux-gnu.so
/usr/lib/python3/dist-packages/PyQt4/uic
/usr/lib/python3/dist-packages/PyQt4/uic/Compiler
/usr/lib/python3/dist-packages/PyQt4/uic/Compiler/qtproxies.py
/usr/lib/python3/dist-packages/PyQt4/uic/Compiler/proxy_metaclass.py
/usr/lib/python3/dist-packages/PyQt4/uic/Compiler/compiler.py
/usr/lib/python3/dist-packages/PyQt4/uic/Compiler/indenter.py
/usr/lib/python3/dist-packages/PyQt4/uic/Compiler/misc.py
/usr/lib/python3/dist-packages/PyQt4/uic/Compiler/qobjectcreator.py
/usr/lib/python3/dist-packages/PyQt4/uic/Compiler/__init__.py
/usr/lib/python3/dist-packages/PyQt4/uic/objcreator.py
/usr/lib/python3/dist-packages/PyQt4/uic/Loader
/usr/lib/python3/dist-packages/PyQt4/uic/Loader/loader.py
/usr/lib/python3/dist-packages/PyQt4/uic/Loader/qobjectcreator.py
/usr/lib/python3/dist-packages/PyQt4/uic/Loader/__init__.py
/usr/lib/python3/dist-packages/PyQt4/uic/driver.py
/usr/lib/python3/dist-packages/PyQt4/uic/properties.py
/usr/lib/python3/dist-packages/PyQt4/uic/uiparser.py
/usr/lib/python3/dist-packages/PyQt4/uic/pyuic.py
/usr/lib/python3/dist-packages/PyQt4/uic/port_v3
/usr/lib/python3/dist-packages/PyQt4/uic/port_v3/invoke.py
/usr/lib/python3/dist-packages/PyQt4/uic/port_v3/ascii_upper.py
/usr/lib/python3/dist-packages/PyQt4/uic/port_v3/proxy_base.py
/usr/lib/python3/dist-packages/PyQt4/uic/port_v3/load_plugin.py
/usr/lib/python3/dist-packages/PyQt4/uic/port_v3/as_string.py
/usr/lib/python3/dist-packages/PyQt4/uic/port_v3/string_io.py
/usr/lib/python3/dist-packages/PyQt4/uic/port_v3/__init__.py
/usr/lib/python3/dist-packages/PyQt4/uic/__init__.py
/usr/lib/python3/dist-packages/PyQt4/uic/widget-plugins
/usr/lib/python3/dist-packages/PyQt4/uic/widget-plugins/phonon.py
/usr/lib/python3/dist-packages/PyQt4/uic/widget-plugins/qtwebkit.py
/usr/lib/python3/dist-packages/PyQt4/uic/widget-plugins/qtdeclarative.py
/usr/lib/python3/dist-packages/PyQt4/uic/widget-plugins/.noinit
/usr/lib/python3/dist-packages/PyQt4/uic/widget-plugins/qaxcontainer.py
/usr/lib/python3/dist-packages/PyQt4/uic/widget-plugins/qscintilla.py
/usr/lib/python3/dist-packages/PyQt4/uic/icon_cache.py
/usr/lib/python3/dist-packages/PyQt4/uic/exceptions.py
/usr/lib/python3/dist-packages/PyQt4/QtSvg.cpython-35m-x86_64-linux-gnu.so
/usr/lib/python3/dist-packages/PyQt4/Qt.cpython-35m-x86_64-linux-gnu.so
/usr/lib/python3/dist-packages/PyQt4/pyqtconfig.py
/usr/lib/python3/dist-packages/PyQt4/QtScriptTools.cpython-35m-x86_64-linux-gnu.so
/usr/lib/python3/dist-packages/PyQt4/pyqtconfig_nd5.py
/usr/lib/python3/dist-packages/PyQt4/QtDesigner.cpython-35m-x86_64-linux-gnu.so
/usr/lib/python3/dist-packages/PyQt4/QtCore.cpython-35m-x86_64-linux-gnu.so
/usr/lib/python3/dist-packages/PyQt4/QtDeclarative.cpython-35m-x86_64-linux-gnu.so
/usr/lib/python3/dist-packages/PyQt4/QtGui.cpython-35m-x86_64-linux-gnu.so
/usr/lib/python3/dist-packages/PyQt4/QtNetwork.cpython-35m-x86_64-linux-gnu.so
/usr/lib/python3/dist-packages/PyQt4/QtXml.cpython-35m-x86_64-linux-gnu.so
/usr/lib/python3/dist-packages/PyQt4/QtWebKit.cpython-35m-x86_64-linux-gnu.so
/usr/lib/python3/dist-packages/PyQt4/QtDBus.cpython-35m-x86_64-linux-gnu.so
/usr/lib/python3/dist-packages/PyQt4/QtAssistant.cpython-35m-x86_64-linux-gnu.so
/usr/lib/python3/dist-packages/PyQt4/__init__.py
/usr/lib/python3/dist-packages/PyQt4/QtXmlPatterns.cpython-35m-x86_64-linux-gnu.so
/usr/lib/python3/dist-packages/PyQt4/QtTest.cpython-35m-x86_64-linux-gnu.so
/usr/lib/python3/dist-packages/PyQt4/QtScript.cpython-35m-x86_64-linux-gnu.so

任何想法?

更新(25/04/18)

我在导入时尝试了python 3.5调试版本:

$ python3-dbg
Python 3.5.2 (default, Nov 23 2017, 16:37:01) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import PyQt4
>>> import PyQt4.QtCore
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named 'PyQt4.QtCore'
Error in sys.excepthook:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in apport_excepthook
    from apport.fileutils import likely_packaged, get_recent_crashes
  File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in <module>
    from apport.report import Report
  File "/usr/lib/python3/dist-packages/apport/report.py", line 30, in <module>
    import apport.fileutils
  File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 23, in <module>
    from apport.packaging_impl import impl as packaging
  File "/usr/lib/python3/dist-packages/apport/packaging_impl.py", line 23, in <module>
    import apt
  File "/usr/lib/python3/dist-packages/apt/__init__.py", line 23, in <module>
    import apt_pkg
ImportError: No module named 'apt_pkg'

Original exception was:
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named 'PyQt4.QtCore'
>>> 

0 个答案:

没有答案