【问题标题】:How to install PyQt on Mac OS X 10.6如何在 Mac OS X 10.6 上安装 PyQt
【发布时间】:2011-02-04 16:49:37
【问题描述】:

我对 Mac OS X 还是很陌生。 当我在安装 python 3.1、Qt 4.6.2 和 SIP 4.10.1 后尝试在 Mac Os X 上安装 PyQt 时,执行 $python3 configure.py 命令时遇到以下错误。

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 吗?

【问题讨论】:

    标签: osx-snow-leopard pyqt


    【解决方案1】:

    尝试使用 brew:

    brew install pyqt
    

    现在比 macports 更强烈推荐。

    【讨论】:

    • 警告!这仅在您使用 brew 中的 python 而不是随 OS X 分发的 python 时才有效。因此,如果 PATH 中的第一个 python 是 OS X,它将不起作用。
    • ... 但是您可以将 PyQt 的路径添加到您的PYTHONPATH。事实上,Homebrew 会为您提供您需要导出的路径,类似于export PYTHONPATH=/usr/local/lib/python2.7/site-packages:$PYTHONPATH。把它放在你的~/.bashrc 文件中,你应该很高兴。
    【解决方案2】:

    QT 和 PyQT 也可以使用 Homebrew 在 OSX 上安装

    【讨论】:

    • 我一直在尝试通过 pip 和 easy_install 安装,但是这两个包都安装有问题。你只是让我不必弄清楚分段错误和依赖关系
    【解决方案3】:

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

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

    【讨论】:

    • 简单,只需将PyQt4源文件文件夹(类似于PyQt-mac-gpl-4.xx.x之类的文件夹)复制到桌面,然后重试。
    【解决方案4】:

    我遇到了这个问题,实际上我的 PyQt 源文件夹位于路径中某处有空格字符的目录中。

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

    【讨论】:

      【解决方案5】:

      您还可以使用PyQtX,它是用于 OS X 的 PyQt 的二进制发行版,还包括 Qt 库。你只需要 Python。

      【讨论】:

      • 这不适用于 OS X 10.8,抱怨官方发行版中没有 Python 2.7。考虑到事实上的 python 是操作系统附带的,这太荒谬了。
      • 如果您在安装前阅读了要求,它明确指出您需要从 Python.org 发行版安装 Python,而不是 Mac OS X 附带的发行版。
      • 这应该是正确的答案,如果你不使用python的brew版本,这是最简单的解决方案。
      【解决方案6】:

      由于您使用的是PyQt v4.7,因此您还需要安装Qt v4.7,请先安装Qt v4.7.1

      【讨论】:

        猜你喜欢
        • 2011-07-29
        • 2010-12-09
        • 2011-12-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2010-11-30
        • 1970-01-01
        • 2011-09-24
        相关资源
        最近更新 更多