2017-04-11 64 views
5

简短版本:如何使PyQt4的configure.py使用虚拟环境中安装的SIP版本?VirtualEnv未正确设置路径,无法使用已安装的模块

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

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

谢谢大家!

编辑:通过它的外观,似乎我的VE不是从正确的位置拉动python库,即使当VE被激活。我添加了一行来激活追加站点包和bin目录的路径和站点包到pythonpath没有成功。它仍然没有找到正确的库。

+0

我还是有点卡住了这一点。我能够激活VE。这里是一些终端输出... ... – jspada

+0

[ve2] [OMMITED]/home/OMMITED/OSE_test/ve2> python2.7 PyQt4_gpl_x11-4.12/configure.py 错误:此版本的PyQt需要SIP v4.19.0或更高版本 [其中sip ./bin/sip – jspada

+0

查看SIP的libs时,看起来它仍在使用系统库而不是VE库。 – jspada

回答

1

您不需要从源代码构建SIP。这里https://pypi.python.org/pypi/SIP

有轮子的文件在我的情况下,在MacOS,我不得不下载车轮并将其重命名诱骗到点子安装它:

$ 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所知道的平台相匹配。

然后,我就能够安装使用python configure-ng.py(使用brew upgrade qt在我的Mac升级QT从5.5到5.8,由于错误https://forum.qt.io/topic/71119/project-error-xcode-not-set-up-properly/7

后来我有一个不错的错误:

$ 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错误

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

1

尝试使用蟒蛇 蟒蛇是一个Python分布,其包括一个替代包管理器(除PIP)和另一种虚拟ENV机制

康达包装与畅达VENV机制工作得很好,所以你不应该“T有这些问题,不需要修改的第三方脚本或手动创建链接

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

创建一个虚拟ENV运行

conda create -n <name> 

激活VENV

source activate <name> 

(使用shell \庆典时)

安装PyQt的运行:

conda install pyqt