简体   繁体   English

PyQt5中的分段错误(核心转储)错误

[英]Segmentation fault (core dumped) Error in PyQt5

I just installed PyQt 5.7.0 on my google compute engine machine which running on a ubuntu 16.04: 我刚刚在我的google计算引擎机器上安装了PyQt 5.7.0,它在ubuntu 16.04上运行:

在此输入图像描述

However, when I wanted to run PyQt and import some module, it produce Segmentation fault (core dumped) error as shown: 但是,当我想运行PyQt并导入一些模块时,它会产生Segmentation fault(core dumped)错误,如下所示:

在此输入图像描述

Can I know how do I solve it? 我可以知道如何解决它吗? I have been searching an answer for this for hours and still can't find an answer. 几个小时以来我一直在寻找答案,但仍然无法找到答案。 Will be greatly appreciated if anyone could help. 如果有人能提供帮助,将不胜感激。

You can try (as explained in the comments) to compile PyQt5.7 yourself, using a different version of Python ( 3.4.3 and 3.4.4 worked for me, everything above 3.5 did not). 您可以尝试(如注释中所述)自己编译PyQt5.7 ,使用不同版本的Python( 3.4.33.4.4为我工作, 3.5以上的所有内容都没有)。 Note that I also compiled Qt5.7 myself, but you can use the one provided by the installer. 请注意,我自己也编译了Qt5.7 ,但您可以使用安装程序提供的版本。 Here is a short, hopefully exhaustive, set of commands to setup a virtual environment: 以下是设置虚拟环境的简短,有希望的详尽命令集:

Install dependencies using apt: 使用apt安装依赖项:

sudo apt-get install -y build-essential libgl1-mesa-dev libx11-dev libxext-dev libxfixes-dev libxi-dev libxrender-dev libxcb1-dev libx11-xcb-dev libxcb-glx0-dev libfontconfig1-dev libfreetype6-dev libglu1-mesa-dev libssl-dev libcups2-dev python3-pip git

Install Python 3.4.4: 安装Python 3.4.4:

cd ~/Downloads
wget https://www.python.org/ftp/python/3.4.4/Python-3.4.4.tar.xz
tar xf Python-3.4.4.tar.xz
cd Python-3.4.4
./configure
sudo make altinstall

Create the virtual environment: 创建虚拟环境:

sudo pip3 install virtualenv
virtualenv -p /usr/local/bin/python3.4 ~/python34
source ~/python34/bin/activate

Install Qt: 安装Qt:

cd ~/Downloads
git clone git://code.qt.io/qt/qt5.git
cd ~/Downloads/qt5
git checkout 5.7
./init-repository
./configure -prefix ~/Qt/5.7/gcc_64 -opensource -nomake examples -nomake tests -release -confirm-license
make -j 5
make install

Install SIP: 安装SIP:

cd ~/Downloads
wget http://downloads.sourceforge.net/project/pyqt/sip/sip-4.18.1/sip-4.18.1.tar.gz
tar xf sip-4.18.1.tar.gz
cd sip-4.18.1
python configure.py
make
sudo make install

Install PyQt: 安装PyQt:

cd ~/Downloads
wget http://downloads.sourceforge.net/project/pyqt/PyQt5/PyQt-5.7/PyQt5_gpl-5.7.tar.gz
tar xf PyQt5_gpl-5.7.tar.gz
cd PyQt5_gpl-5.7
python configure.py --qmake ~/Qt/5.7/gcc_64/bin/qmake --disable QtPositioning --no-qsci-api --no-designer-plugin --no-qml-plugin --confirm-license
make -j 5
sudo make install

Caveats: 注意事项:

  • I'm going to assume that you can't run any GUI programs right now in your vm. 我将假设您现在无法在您的虚拟机中运行任何GUI程序。
  • I'm not that familiar with GCE platform and have not tried what I'm going to propose 我对GCE平台并不熟悉,也没有尝试过我要提出的建议

Follow the steps at Your desktop on Google Cloud Platform to install a desktop GUI manager in the GCE vm (it will be X11-based for Linux OS), as well as vnc server. 按照Google云端平台上桌面上的步骤在GCE虚拟机中安装桌面GUI管理器(它将基于X11,适用于Linux操作系统)以及vnc服务器。

Once you are vnc'd in to your vm using realvnc or tightvnc viewer, a GUI app will likely run. 使用realvnc或tightvnc查看器进入vm后,可能会运行GUI应用程序。 You may have to change the X11 DISPLAY variable -- eventhough the above link does not discuss this -- because AFAIR *nix systems use a separate desktop session for VNC than the one currently logged in. 您可能必须更改X11 DISPLAY变量 - 尽管上面的链接没有讨论这个 - 因为AFAIR * nix系统使用单独的桌面会话进行VNC而不是当前登录。

I doubt it will run if there is no user logged on to the GCE vm. 如果没有用户登录到GCE虚拟机,我怀疑它会运行。

If you installed PyQt5 with apt or apt-get, now do also 如果您使用apt或apt-get安装PyQt5,现在也可以

sudo pip3 install pyqt5 sudo pip3安装pyqt5

You cannot run a GUI program (PyQt) remotely, unless both machines use X11 protocol with properly set DISPLAY variables and xhost permissions. 您不能远程运行GUI程序(PyQt),除非两台机器都使用X11协议并正确设置DISPLAY变量和xhost权限。 I doubt that Google compute engine is configurable to run in the X11 mode. 我怀疑Google计算引擎是否可以配置为在X11模式下运行。

当你导入PyQt5时,它也会导入PyQt5.QtCore,因为PyQt5.QtCore是PyQt5的一部分。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM