【问题标题】:Installing PyQt4 in a virtualenv在 virtualenv 中安装 PyQt4
【发布时间】:2012-10-07 16:36:33
【问题描述】:

我正在尝试在 virtualenv 中安装 PyQT4。我正在运行 Python3.2.1。

这是我到目前为止所做的:

sudo apt-get install qt4-dev-tools

效果很好

我下载了 PyQt-x11-gpl-4.9.5 和 sip-4.14

在 virtualenv 中我安装了 sip。没有出现错误。

当我尝试打电话时:

python3.2 configure.py

对于我的 PyQt,它让我接受许可证,做一堆没有错误的东西然后说:

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] [-P] [-r] [-s suffix] [-t tag] [-T] [-w] [-x feature] [-X id:file] [-z file] [file]
Error: Unable to create the C++ code.

据我所知,我的问题在于我运行了错误版本的 Qt。我不太确定如何检查我的 Qt 版本,但我安装了 QtAssistant,它指的是 Qt4.8,所以我假设我有那个。

所以如果是版本问题:

1. how do I reliably check what version of Qt I'm running?
2. What version should I be running

否则:

1. Wtf?

我们将不胜感激。

PS

我已经看过How to configure PyQt4 for Python 3 in Ubuntu?。没有什么能帮到我。

【问题讨论】:

    标签: python ubuntu installation pyqt4 python-3.2


    【解决方案1】:

    我总是在安装 PyQt4 之前安装所有这些库:

    sudo apt-get install libqt4-assistant libqt4-core \
    libqt4-dbg libqt4-dbus libqt4-designer libqt4-dev \
    libqt4-gui libqt4-help libqt4-network libqt4-opengl \
    libqt4-qt3support libqt4-script \
    libqt4-svg libqt4-test libqt4-webkit libqt4-webkit-dbg \
    libqt4-xml libqt4-xmlpatterns libqt4-xmlpatterns-dbg \
    libqtcore4 libqtgui4 qt4-demos qt4-designer qt4-dev-tools \
    qt4-doc qt4-doc-html qt4-qtconfig qtcreator libqtwebkit-dev \
    qt4-qmake cmake r-base-dev libcurl4-gnutls-dev 
    

    您可以通过以下方式验证qt版本:

    qmake --version
    

    除此之外我没有发现任何问题,我将其发布为答案只是因为库列表不能很好地适合评论... 哦还有一件事,你应该先编译和安装 sip,然后是 PyQt4

    【讨论】:

    • 谢谢,我还是有同样的问题
    【解决方案2】:

    似乎问题出在 configure.py 文件中。要解决这个问题,只需确保 PyQt 源文件位于没有空格的路径中。

    查看此处了解更多信息: How to install PyQt on Mac OS X 10.6

    【讨论】: