6

短版:如何让 PyQt4 的 configure.py 使用安装在虚拟环境中的 SIP 版本?

长版:我知道这个问题的变化在这里已经被问了一百万次,但我似乎找不到答案。我正在尝试在虚拟环境 (VE) 中安装 SIP 和 PyQt4。我无法将它安装到主系统,因为它是一台工作计算机。我们有旧版本的 PyQt,所以我无法从站点包中复制。

我已经在我的 VE 中安装了 SIP(​​configure.py --incdir,make,make install),但是当我在 PyQt4 上运行 configure 时出现错误:错误:此版本的 PyQt 需要 SIP v4.19.0 或更高版本。我安装了 4.19.2 版。运行 sipconfig 时,它告诉我它仍在使用系统版本,即使激活了 VE。我如何告诉 configure.py for PyQt 使用安装在 VE 中的包?

谢谢大家!

编辑:看起来,我的 VE 似乎没有从正确的位置拉出 python 库,即使 VE 被激活。我添加了一行来激活将站点包和 bin dirs 路径和站点包附加到 pythonpath,但没有成功。它仍然没有找到正确的库。

4

3 回答 3

1

在您的虚拟环境中安装 pip。并检查 pip 是否使用正确的目录which pip。如果它没有使用正确的目录,试试这个:

pip install --target=<location of site packages of your pip in your virtual env> sip==4.19

如果您收到名为权限被拒绝的错误,请使用

sudo chown -R your_username:your_username path/to/virtuaelenv/

然后做:

pip install PyQt4

如果上述方法均无效,请按照以下说明操作:

http://movingthelamppost.com/blog/html/2013/07/12/installing_pyqt____because_it_s_too_good_for_pip_or_easy_install_.html

于 2017-04-20T05:34:06.213 回答
1

尝试使用 anaconda anaconda 是一个 python 发行版,它包括一个替代包管理器(除了 pip)和一个替代虚拟 env 机制

conda 包可以很好地与 conda venv 机制配合使用,因此您不应该遇到这些问题,并且不需要修改 3rd 方脚本或手动创建链接

安装自:https ://www.continuum.io/downloads

创建一个虚拟环境运行

conda create -n <name>

激活venv

source activate <name>

(使用 shell\bash 时)

安装 pyqt 运行:

conda install pyqt
于 2017-04-20T05:49:39.910 回答
1

您无需从源代码构建 SIP。这里有轮子文件https://pypi.python.org/pypi/SIP

就我而言,在 macos 上,我必须下载轮子并重命名它以欺骗 pip 安装它:

$ curl -L -O 'https://pypi.python.org/packages/f9/8c/23d88c8e4d457031111b70ec25bf97844776ec16cfd4688f318dcaeba5d6/sip-4.19.2-cp35-cp35m-macosx_10_6_intel.whl#md5=eb42e9975cae2b936ecc980b9a3266ed'
$ mv sip-4.19.2-cp35-cp35m-*.whl sip-4.19.2-cp35-none-macosx_10_11_x86_64.whl
$ pip install sip-4.19.2-cp35-none-macosx_10_11_x86_64.whl

皮普比较傻。文件名必须与 pip 为您的平台知道的内容匹配。

然后,由于错误https://forum.qt.io/topic/71119/project-error-xcode-not-set-up,我能够安装 using python configure-ng.py(在我的 mac 上将 qt 从 5.5 升级到 5.8 using之后) -正确/7brew upgrade qt

然后我得到了一个很好的错误:

$ python configure-ng.py --verbose
Querying qmake about your Qt installation...
Determining the details of your Qt installation...
/usr/local/Cellar/qt5/5.8.0_2/bin/qmake -o qtdetail.mk qtdetail.pro
Info: creating stash file /Users/jrwren/Downloads/PyQt4_gpl_mac-4.12/.qmake.stash
make -f qtdetail.mk
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -c -pipe -stdlib=libc++ -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -mmacosx-version-min=10.9  -O2 -std=gnu++11 -Wall -W -fPIC -DQT_NO_DEBUG -DQT_CORE_LIB -I. -I/usr/local/Cellar/qt/5.8.0_2/lib/QtCore.framework/Headers -I. -I/usr/local/Cellar/qt/5.8.0_2/mkspecs/macx-clang -F/usr/local/Cellar/qt/5.8.0_2/lib -o qtdetail.o qtdetail.cpp
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -headerpad_max_install_names -stdlib=libc++ -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -mmacosx-version-min=10.9  -o qtdetail.app/Contents/MacOS/qtdetail qtdetail.o   -F/usr/local/Cellar/qt/5.8.0_2/lib -framework QtCore -framework DiskArbitration -framework IOKit
qtdetail.app/Contents/MacOS/qtdetail
This is the GPL version of PyQt 4.12 (licensed under the GNU General Public
License) for Python 3.5.1 on darwin.
Error: This version of PyQt4 and the commercial version of Qt have incompatible
licenses.

但这不是 SIP 错误。

于 2017-04-19T19:11:01.000 回答