VirtualEnv not setting paths correctly, unable to use installed module
Asked Answered
T

3

6

Short Version: How do I have PyQt4's configure.py use the SIP version installed in the Virtual Env?

Long version: I know variations on this question have been asked like a million times here but I cannot seem to find the answer. I am trying to install SIP and PyQt4 in a Virtual Env (VE). I am unable to install it to the main system as it is a work computer. We have an older version of PyQt so I am unable just to copy from the site packages.

I have installed SIP in my VE (configure.py --incdir , make, make install) however when I go to run configure on PyQt4 I get the error: Error: This version of PyQt requires SIP v4.19.0 or later. I installed Version 4.19.2. When running sipconfig it tells me it is still using the systems version, even with the VE activated. How do I tell configure.py for PyQt to use the package installed in the VE?

Thanks all!

EDIT: By the looks of it, it seems that my VE is not pulling the python libs from the right place, even when the VE is activated. I added a line to activate append the site-packages and bin dirs the the path and the site-packages to the pythonpath without success. It is still not finding the correct libs.

Tetrahedron answered 11/4, 2017 at 18:58 Comment(6)
I am still a little stuck on this. I was able to activate the VE. Here is some terminal output...Tetrahedron
[ve2] [OMMITED] /home/OMMITED/OSE_test/ve2 > python2.7 PyQt4_gpl_x11-4.12/configure.py Error: This version of PyQt requires SIP v4.19.0 or later [ve2] [OMMITED] /home/OMMITED/OSE_test/ve2 > which sip ./bin/sipTetrahedron
When looking at the libs for SIP, it looks like it is still using the System libs and not the VE libs.Tetrahedron
> whichpy sipconfig /a/path/on/sys/python2.7/sipconfig.pyTetrahedron
Do not update the question in the comments - edit the main post, so the main content is up to date - it states the actual, current problem you have.Calisa
Could you show step by step: you actions and output? Looks like VE wasn't well activated or some scripts didn't get correct path vars.Amy
C
1

You need not build SIP from source. There are wheel files here https://pypi.python.org/pypi/SIP

In my case, on macos, I had to download the wheel and rename it to trick pip into installing it:

$ 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 is rather stupid. The filename has to match something that pip knows for your platform.

Then, I was able to install using python configure-ng.py (after upgrading qt on my mac from 5.5 to 5.8 using brew upgrade qt, due to a bug https://forum.qt.io/topic/71119/project-error-xcode-not-set-up-properly/7

Then I got a nice error:

$ 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.

But it wasn't a SIP error.

Carolanncarole answered 19/4, 2017 at 19:11 Comment(0)
Z
1

Install pip in your virtual env. And check if the pip is using the correct directory using which pip. If it is not using the correct directory, Try this:

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

If you get an error called permission denied, use

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

Then do:

pip install PyQt4

If none of the above works, please follow these instructions:

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

Zhang answered 20/4, 2017 at 5:34 Comment(0)
L
1

Try using anaconda anaconda is a python distribution that includes an alternative package manager (in addition to pip) and an alternative virtual env mechanism

conda packages work well with the conda venv mechanism, so you shouldn't have these issues, and doesn't require modifying 3rd party scripts or manually creating links

install from: https://www.continuum.io/downloads

to create a virtual env run

conda create -n <name>

activate the venv

source activate <name>

(when using shell \ bash)

to install pyqt run:

conda install pyqt
Lawry answered 20/4, 2017 at 5:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.