I have installed virtualenv and virtualenvwrapper on Ubuntu 16.04 I have created one enviroment named env1
$ sudo apt-get install python-pip
$ pip install virtualenv
$ pip install --upgrade pip
$ pip install virtualenvwrapper
$ export WORKON_HOME=~/Envs
$ mkdir -p $WORKON_HOME
$ source /usr/local/bin/virtualenvwrapper.sh
$ mkvirtualenv env1
Once in (env1) I have installed several packages
(env1) $ pip install numpy
(env1) $ pip install scipy
(env1) $ pip install matplotlib
(env1) $ apt-get install python-tk
I have also installed opencv3 (I am not copying how because is too long)
I am using env1 for a specific project.
Now I want to start another project using the same packages, but I also want to add other packages.
I have created env2, and I was wondering if it is possible to copy env1 to env2 without the need to re-install everything again from scratch.
Your best option is to do this:
virtualenv-1:
pip freeze > requirements.txt
virtualenv-2:
pip install -r requirements.txt
Assuming they are both the on the same system and use the same Python, it is somewhat possible to just copy the site-packages:
cp -Rp /environments/virtualenv-1/lib/python2.7/site-packages \
/environments/virtualenv-2/lib/python2.7/site-packages
This won't necessarily work though:
So your best bet is to pip freeze and reinstall from that file.
pip install virtualenvwrapper and use the cpvirtualenv command
cpvirtualenv ENVNAME [TARGETENVNAME]
http://virtualenvwrapper.readthedocs.io/en/latest/command_ref.html#cpvirtualenv
Remember to heed the warning
Copying virtual environments is not well supported. Each virtualenv has
path information hard-coded into it, and there may be cases where the copy
code does not know to update a particular file. Use with caution.
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