2010-04-06 128 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