2017-04-11 31 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 
相關問題