I have set up a python virtual env using
$ virtualenv --system-site-packages env
It works fine on the machine where I have set up the virtual env and I can access all the global packages in my script.
I then copied this virtual env to a different machine by following these steps-
- Making the virtual env relocatable on my local machine
$ virtualenv --relocatable env
- Copying the
env
folder over to the remote machine. - Modify the
env/bin/activate
script to change theVIRTUAL_ENV
path on the remote machine
With this I can access all my local packages just fine. But it cannot access the system level packages for some reason. The system level package I am trying to use is psycopg2.
However doing something like below on the remote machine gives me an access to the psycopg2 module
$ ln -s /usr/lib64/python2.7/dist-packages/psycopg2 $virtual_env/lib/python2.7/site-packages
or
$ cp -R /usr/lib64/python2.7/dist-packages/psycopg2 $virtual_env/lib/python2.7/site-packages
Is there any way I can get this working without having to do this hack ?
How does the --system-site-packages
option work?
From what I see --system-site-packages option does not do a hard copy of system level packages to the virtual env
.
So does it set some kind of a path variable in the scripts which I can change and get this working ?