Is it possible to add PyQt4/PySide packages on a Virtualenv sandbox? Is it possible to add PyQt4/PySide packages on a Virtualenv sandbox? python python

Is it possible to add PyQt4/PySide packages on a Virtualenv sandbox?


It should be enough to create an empty virtualenv and then copy the contents of the .../site-packages/PyQt4 directories into it.

I suggest to install PyQt4 once globally, make a copy of the directory, uninstall it and then use this trick to create VEs.


I have the same problem. I use virtualenvwrapper, so I wrote this script to create a link to PyQt in every new virtual environment. Maybe is useful for someone else:

#!/bin/bash# This hook is run after a new virtualenv is activated.# ~/.virtualenvs/postmkvirtualenvLIBS=( PyQt4 sip.so )PYTHON_VERSION=python$(python -c "import sys; print (str(sys.version_info[0])+'.'+str(sys.version_info[1]))")VAR=( $(which -a $PYTHON_VERSION) )GET_PYTHON_LIB_CMD="from distutils.sysconfig import get_python_lib; print (get_python_lib())"LIB_VIRTUALENV_PATH=$(python -c "$GET_PYTHON_LIB_CMD")LIB_SYSTEM_PATH=$(${VAR[-1]} -c "$GET_PYTHON_LIB_CMD")for LIB in ${LIBS[@]}do    ln -s $LIB_SYSTEM_PATH/$LIB $LIB_VIRTUALENV_PATH/$LIB done

link to gist


Linux debian, python 2.7:

  • Install python-qt4 globaly: sudo apt-get install python-qt4
  • Create symbolic link of PyQt4 to your virtual env ln -s /usr/lib/python2.7/dist-packages/PyQt4/ ~/.virtualenvs/myEnv/lib/python2.7/site-packages/
  • Create symbolic link of sip.so to your virtual envln -s /usr/lib/python2.7/dist-packages/sip.so ~/.virtualenvs/myEnv/lib/python2.7/site-packages/