I want to create one virtualenv
using another as the starting point, is this possible?
I have to use cases in mind:
Let's say I have a two virtualenv
one for production and one for development. The development environment requires the same packages as the production environment, but it requires others I don't want in the production environment. I don't want to install the common packages twice.
I want to experiment with a development version of a package, say matplotlib
for example. The development version of the package has the same requirements as the stable version. So I create a virtualenv
called matplotib_stable
and install the requirements and the stable version. Then I create a second virtualenv
called matplotlib_dev
and use matplotlib_stable
as a starting point (for the matplotlib
requirements) but then I install the development version.
How do I install from a local cache with pip? seems to address the issue of downloading packages, but I don't think it deals with modifying sys.path
.
virtualenv-clone will be installed inside newenv. Now while logged-in as newenv we can create a copy of any existing environment. For example creating the copy of ProjectAenv: (newenv): virtualenv-clone ProjectAenv ProjectBenv (newenv): deactivate # to come out from newenv.
If you build with virtualenv --system-site-packages ENV , your virtual environment will inherit packages from /usr/lib/python2. 7/site-packages (or wherever your global site-packages directory is).
1 Answer. Kindly be informed that yes, it is possible to move it on the same platform. You can simply use --relocatable on an existing environment. But it will get changed based on the new location in order to call python and pip, etc.
One solution is to use virtualenvwrapper
's add2virtualenv
command. This
Adds the specified directories to the Python path for the currently-active virtualenv.
So if I have two virtualenv
, ENV1
and ENV2
, and I want ENV2
to access the packages in ENV1
, then I need to:
activate ENV2
:
workon ENV2
add ENV1
's site-packages directory using add2virtualenv
:
add2virtualenv $WORKON_HOME/ENV1/lib/python2.6/site-packages
The above assumes $WORKON_HOME
is the location of your virtualenv directories, and that you are using python2.6, so obviously adjust those accordingly.
While this provides access to the packages it does not adjust the shell path. In other words, scripts installed to the bin
directory are not accessible using this method.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With