VirtualEnv sets paths incorrectly, cannot use installed module

Short version. How to configure PyQt4 configure.py to the SIP version installed in Virtual Env?

Long version: I know that variations on this question have been asked here about a million times, but I can not find the answer. I am trying to install SIP and PyQt4 in Virtual Env (VE). I can not install it in the main system, since it is a working computer. We have an older version of PyQt, so I can’t just copy from site packages.

I 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: SIP v4.19.0 or later is required for this version of PyQt, I installed version 4.19.2. When running sipconfig, it tells me that it is still using the system version, even if VE is activated. How to tell configure.py for PyQt to use the package installed in VE?

Thanks everyone!

EDIT: In appearance, it looks like my VE is not pulling python libs from the right place, even when the VE is activated. I added a line to activate adding site packages and bin dirs paths and site packages to pythonpath without success. He still cannot find the correct libraries.

+5
source share
3 answers

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

In my case, on macos, I had to load 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 pretty dumb. The file name should match what the protocol 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 error https://forum.qt.io/topic/71119/project-error- xcode-not-set-up-properly / 7

Then I got a good 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 was not a SIP error.

+1
source

Install pip in your virtual env. And check if pip uses the correct directory using which pip . If it does not use the correct directory, try the following:

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

If you receive an "Allowed" error message, use

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

Then do:

 pip install PyQt4 

If none of the above actions is performed, follow these steps:

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

+1
source

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 should not have these problems and do not need to modify third-party scripts or create links manually

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

to create virtual env run

 conda create -n <name> 

activate venv

 source activate <name> 

(when using the \ bash shell)

to install pyqt run:

 conda install pyqt 
+1
source

Source: https://habr.com/ru/post/1266601/


All Articles