如何在Ubuntu中配置PyQt4 for Python 3?

前端之家收集整理的这篇文章主要介绍了如何在Ubuntu中配置PyQt4 for Python 3?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
这个问题最初是在askubuntu.com问的,但没有注意,所以我想这可能是一个更好的地方要问。

我安装了PyQt4与突触。

我使用Python3,所以我需要在eclipse中配置PyQt4的路径,但似乎突触只安装PyQt4 for python 2,因为我只在python 2.6和2.7中找到相对的文件文件夹。

那么我该如何使PyQt4与Python 3和eclipse一起使用?

谢谢。

更新:

我试图配置它以下这篇文章http://ubuntuforums.org/showthread.php?p=10914908#post10914908

但是,在遵循所有的指令没有任何错误发生的方式,我得到错误从运行这个代码在python 3.2:

>>> import PyQt4

错误信息是:

Traceback (most recent call last):
  File "<stdin>",line 1,in <module>
ImportError: No module named PyQt4

但奇怪的是,相同的代码结果没有错误在python 2.7(我的2.7和3.2安装在我的机器上)

安装编译所需的软件包(我不确定需要这些软件):
sudo apt install build-essential python3-dev libqt4-dev

下载最新的SIP – sip-4.12.4.tar.gz(Linux,UNIX,MacOS / X源)源。

打开包装并进入目录:

vic@wic:~/Desktop/sip-4.12.4$ python3 configure.py 
This is SIP 4.12.4 for Python 3.2 on linux2.
The SIP code generator will be installed in /usr/bin.
...
Creating sip module Makefile...

vic@wic:~/Desktop/sip-4.12.4$ make
make[1]: Entering directory `/home/vic/Desktop/sip-4.12.4/sipgen'
...
make[1]: Leaving directory `/home/vic/Desktop/sip-4.12.4/siplib'

vic@wic:~/Desktop/sip-4.12.4$ sudo make install
make[1]: Entering directory `/home/vic/Desktop/sip-4.12.4/sipgen'
...
cp -f /home/vic/Desktop/sip-4.12.4/sipdistutils.py /usr/lib/python3/dist-packages/sipdistutils.py

vic@wic:~/Desktop/sip-4.12.4$

下载最新的PyQt – PyQt-x11-gpl-4.8.5.tar.gz(Linux,UNIX源)的源代码,并安装它:

vic@wic:~/Desktop/PyQt-x11-gpl-4.8.5$ python3 configure.py 
Determining the layout of your Qt installation...
This is the GPL version of PyQt 4.8.5 (licensed under the GNU General Public License) for Python 3.2 on linux2.

Type '2' to view the GPL v2 license.
Type '3' to view the GPL v3 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...
...
Checking to see if the dbus support module should be built...
The Python dbus module doesn't seem to be installed.
Qt v4.7.2 free edition is being used.
SIP 4.12.4 is being used.
The Qt header files are in /usr/include/qt4.
...
Creating pyqtconfig.py...

vic@wic:~/Desktop/PyQt-x11-gpl-4.8.5$ make
make[1]: Entering directory `/home/vic/Desktop/PyQt-x11-gpl-4.8.5/qpy'
...
make[1]: Leaving directory `/home/vic/Desktop/PyQt-x11-gpl-4.8.5/designer'

vic@wic:~/Desktop/PyQt-x11-gpl-4.8.5$ sudo make install
make[1]: Entering directory `/home/vic/Desktop/PyQt-x11-gpl-4.8.5/qpy'
...
cp -f PyQt4.api /usr/share/qt4/qsci/api/python/PyQt4.api

注意,我正在发布python3而不是python。

原文链接:https://www.f2er.com/ubuntu/349263.html

猜你在找的Ubuntu相关文章