本文介绍了如何在python 2.7的Ubuntu 12.04上安装PyQt?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能有类似的问题,例如这个问题,但是我没有找不到我的答案.

There may be some similar questions like this one, but I didn't find any answer for me.

我尝试了一些方法来做到这一点:

I tried some ways to do it like:

sudo aptitude install python-qt4-dev python-sip4 python-sip4-dev

来自: https://groups.google.com /forum/#!topic/mnemosyne-proj-devel/VQQzjhARWoA

我尝试过:

sudo aptitude install python-qt4

来自: http: //www.saltycrane.com/blog/2008/01/how-to-install-pyqt4-on-ubuntu-linux/

每次以上安装后,我都会收到错误消息:

Every time after above installations I got error:

$python2.7
Python 2.7.3 (default, Aug  1 2012, 05:14:39)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import PyQt4
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named PyQt4

我还尝试通过从以下位置下载PyQt4的源进行安装: http://www.riverbankcomputing.co.uk/software/pyqt/download并从以下网站ip饮: http://www.riverbankcomputing.co.uk/software/sip/下载

I also tried to install it from source downloading PyQt4 from:http://www.riverbankcomputing.co.uk/software/pyqt/downloadand sip from: http://www.riverbankcomputing.co.uk/software/sip/download

然后我在安装PyQt4时遇到错误提示:

Then I got error tring to install PyQt4:

$ sudo python configure.py --verbose
Determining the layout of your Qt installation...
/usr/bin/qmake -o qtdirs.mk qtdirs.pro
make -f qtdirs.mk
g++ -c -m64 -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_CORE_LIB -I/usr/share/qt4/mkspecs/linux-g++-64 -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4 -I. -o qtdirs.o qtdirs.cpp
qtdirs.cpp:1:28: fatal error: QCoreApplication: No such file or directory
compilation terminated.
make: *** [qtdirs.o] Error 1
Error: Failed to determine the layout of your Qt installation. Try again using
the --verbose flag to see more detail about the problem.

我的问题是:在Ubuntu 12.04上安装PyQt4的正确有效方法是什么?

My question is: What is proper and effective way to install PyQt4 on Ubuntu 12.04?

推荐答案

实际上,您在使用时确实为Qt4安装了python绑定:

You did in fact properly install the python bindings for Qt4 when you used:

sudo aptitude install python-qt4

通常应使用发行版提供的软件包-Ubuntu提供的软件包完全可以满足您的需求.

You should usually use the Distribution-provided packages - the Ubuntu-provided packages are perfectly adequate for your needs.

让我感到困惑的是安装Ubuntu软件包后收到的错误.我只是在Ubuntu 12.04安装上尝试过,它对我有用.这向我表明,您当前在系统上安装的Ubuntu在某种程度上已被破坏.

What's puzzling me is the error you got after installing the Ubuntu package. I just tried this on a Ubuntu 12.04 installation and it worked for me. That suggests to me that your current installation of Ubuntu on your system is broken in some way.

您可以尝试完全清除python-qt4软件包并再次重新安装;

You could try completely purging the python-qt4 package and reinstalling it again;

sudo apt-get remove --purge python-qt4

如果您还发出:

sudo apt-get clean

...将从系统中删除所有已下载的软件包文件,因此,当您发出

... that will remove any downloaded package files from the system, so that apt will then download the package file again when you issue a

sudo apt-get install python-qt4

如果仍然无法正常工作,则说明Ubuntu安装确实发生了很奇怪的事情,完全重新安装Ubuntu可能是明智的选择.

If that still doesn't work, then something very odd indeed is going on with your Ubuntu installation, and it might be wise to completely reinstall Ubuntu.

这篇关于如何在python 2.7的Ubuntu 12.04上安装PyQt?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 19:37