Skip to content
Create a gist now

Instantly share code, notes, and snippets.

Creates a symlink to PyQt libraries when a new virtual environment is created
# This hook is run after a new virtualenv is activated.
# ~/.virtualenvs/postmkvirtualenv
libs=( PyQt4 )
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[@]}
ln -s $lib_system_path/$lib $lib_virtualenv_path/$lib
nerdoc commented Jan 17, 2014

Under Ubuntu (13.10), this links to /usr/lib/python3.3/site-packages/ and /usr/lib/python3.3/site-packages/PyQt4, which are non-existent. These files are living in /usr/lib/python3/dist-packages/
This is because Debian/Ubuntu installs Python packages into dist-packages, not site-packages.
So the script is not usable under *buntu/Debian

bootchk commented May 12, 2014

Yes, but it is useable if you build PyQt yourself, since it installs to site-packages. But then, python3 on Ubuntu/Debian does not seem to have site-packages in its PYTHONPATH.

So is there a general problem, that Debian has broken a Python convention that the default PYTHONPATH includes site-packages? Is that the mess that virtualenv is designed to fix?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.