2010-04-06 131 views
10

我对Mac OS X很新颖。 当我试图在安装python 3.1,Qt 4.6.2和SIP 4.10.1之后在Mac Os X上安装PyQt时遇到以下错误,当我执行$ python3 configure.py命令。如何在Mac OS X上安装PyQt 10.6

Determining the layout of your Qt installation... 
This is the GPL version of PyQt 4.7 (licensed under the GNU General Public 
License) for Python 3.1 on darwin. 

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 
Checking to see if the QtGui module should be built... 
Checking to see if the QtHelp module should be built... 
Checking to see if the QtMultimedia module should be built... 
Checking to see if the QtNetwork module should be built... 
Checking to see if the QtOpenGL module should be built... 
Checking to see if the QtScript module should be built... 
Checking to see if the QtScriptTools module should be built... 
Checking to see if the QtSql module should be built... 
Checking to see if the QtSvg module should be built... 
Checking to see if the QtTest module should be built... 
Checking to see if the QtWebKit module should be built... 
Checking to see if the QtXml module should be built... 
Checking to see if the QtXmlPatterns module should be built... 
Checking to see if the phonon module should be built... 
Checking to see if the QtAssistant module should be built... 
Checking to see if the QtDesigner module should be built... 
Qt v4.6.2 free edition is being used. 
Qt is built as a framework. 
SIP 4.10.1 is being used. 
The Qt header files are in /usr/include. 
The shared Qt libraries are in /Library/Frameworks. 
The Qt binaries are in /Developer/Tools/Qt. 
The Qt mkspecs directory is in /usr/local/Qt4.6. 
These PyQt modules will be built: QtCore. 
The PyQt Python package will be installed in 
/Library/Frameworks/Python.framework/Versions/3.1/lib/python3.1/site-packages. 
PyQt is being built with generated docstrings. 
PyQt is being built with 'protected' redefined as 'public'. 
The Designer plugin will be installed in 
/Developer/Applications/Qt/plugins/designer. 
The PyQt .sip files will be installed in 
/Library/Frameworks/Python.framework/Versions/3.1/share/sip/PyQt4. 
pyuic4, pyrcc4 and pylupdate4 will be installed in 
/Library/Frameworks/Python.framework/Versions/3.1/bin. 
Generating the C++ source for the QtCore module... 
sip: Usage: sip [-h] [-V] [-a file] [-b file] [-c dir] [-d file] [-e] [-g] [-I dir] [-j #] [-k] [-m file] [-o] [-p module] [-r] [-s suffix] [-t tag] [-w] [-x feature] [-z file] [file] 
Error: Unable to create the C++ code. 

有人在这里在Mac OS X 10.6.2上成功安装了PyQt吗?

回答

6

我有和你一样的问题。解决方案相当简单。

由于PyQt4的configure.py中存在一个bug,因此您的PyQt4源目录路径中不应该有空格字符。错误是由于configure.py在带空格的输入路径上调用sip可执行文件时语法错误导致的。

+1

你如何解决它? – 2012-11-14 12:00:24

+0

简单,只需将PyQt4源文件文件夹(名为PyQt-mac-gpl-4.xx.x的文件夹)复制到桌面,然后重试。 – 2013-09-10 14:54:41

8

QT和PyQt的也可使用Homebrew

+0

我一直尝试通过pip和easy_install进行安装,但这两个软件包在安装时都存在问题。你只是救了我不得不找出分割错误和依赖关系 – pocketfullofcheese 2013-01-12 23:10:28

0

OSX上安装由于您使用PyQt v4.7您需要安装Qt v4.7也继续前进,先安装Qt v4.7.1

+0

没有它不是这样的 – AbiusX 2012-06-28 20:36:26

4

我有这个问题,实际上我的PyQt源文件夹是在一个目录中有一个空间字符的路径。

我能够通过将PyQt源文件夹移动到根目录并从那里运行python configure.py来完成这项工作。

1

您也可以使用PyQtX,它是OS X的PyQt的二进制发行版,也包含Qt库。你只需要Python就可以了。使用BREW

+1

这不适用于OS X 10.8,抱怨没有从官方发布的Python 2.7。考虑到事实上的python是与操作系统一起出现的,这太荒谬了。 – sorin 2013-07-12 10:49:09

+0

如果您在安装前阅读了要求,它清楚地表明您需要从Python.org发行版安装Python,而不是使用Mac OS X附带的Python。 – AbiusX 2013-09-22 17:56:58

+1

这应该是正确的答案,它是最简单的解决方案if你不使用Python的brew版本。 – Jim 2014-02-23 23:17:51

32

尝试:

brew install pyqt 

更强烈建议比现在MacPorts的。

+3

警告!这只有在你使用brew中的python而不是OS X上发布的python时才有效。所以如果PATH中的第一个python是OS X,那么它将不起作用。 – sorin 2013-07-12 10:43:03

+1

...但您可以将PyQt的路径添加到您的'PYTHONPATH'中。事实上,Homebrew会为你提供你需要导出的路径,这些内容是'export PYTHONPATH =/usr/local/lib/python2.7/site-packages:$ PYTHONPATH'。把它放在'〜/ .bashrc'文件中,你应该很好。 – 2014-10-20 09:29:08