Cloning or copying a virtual environment

Photo by Jørgen Håland on Unsplash

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?

  1. 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.




Python Developer | Django Developer | Python Enthusiast

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Flutter on Surface Duo: Part 1

German Lecture Notes -4 Adjectivdeklination (Adjective Endings)

4 Things You Should Stop Saying to Developers

How to publish Android library to Github package as a Maven repository

The Best Evernote Alternatives for Note-taking and Task Management

6 Tips for an Amazing Qiskit Hackathon Presentation

Our AR Development Experience. Annual Halloween Hackathon

Switching to Istio as the primary ingress

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Allwin Raju

Allwin Raju

Python Developer | Django Developer | Python Enthusiast

More from Medium

Best module for python developer.


How Python Evolved as a Programming Language

Top 8 Features of Python Language That You Must Know

Top 8 Python Features