I recently came across a situation where I had to copy my virtual environment and paste it into another directory. This worked perfectly fine. But I noticed that the VIRTUAL_ENV path inside the “activate” file was still pointed to the original directory from where it is copied from.
I searched for ways to completely clone a virtual environment from one directory to another. The following method was much simpler and worked perfectly fine.
How does it work?
- Install the virtualenv-clone inside the virtual environment which you wish to copy elsewhere.
$ pip install virtualenv-clone
2. We need to run the following command providing the path of the original virtualenv directory and the target directory.
$ virtualenv-clone source/venv target/venv
That is it. The new virtual environment will be cloned to the target directory. We can go to the target directory, activate the virtual environment, and get started.