I have an existing Python django Project running in Web Server. Now the client needs to make some changes in the existing code. So I need to set it up in my Local Machine. All the packages needed for this project is installed in a Virtual environment. How can I copy or clone this virtual environment to my Local machine to run this Project.
Asked
Active
Viewed 2.3k times
2 Answers
53
- Run
pip freeze > requirements.txt
on the remote machine - Copy that
requirements.txt
file to your local machine - In your local virtual environment, run
pip install -r requirements.txt
And, so long as all of the requirements are well behaved Python packages, you should be good to go.

David Wolever
- 148,955
- 89
- 346
- 502
-
1Did'nt know about pip freeze. Is that all packages that are installed on the machine. Or is it only those that are installed by pip? – Niclas Nilsson Feb 09 '12 at 08:31
-
1All of the packages installed on the machine (or in the virtual environment you're currently in). – David Wolever Feb 09 '12 at 08:31
-
2What if you don't want to install them again ? Can you copy installed package library in new virtual environment's location ? – Jay Modi Nov 19 '15 at 07:37
-
11What if I want to copy the entire environment to an offline computer? – Wesley Ranger Mar 09 '17 at 01:49
-
This would work only for PyPI available packages right? If there are any custom libraries those would be missed isn't it – Akshay Gehi Sep 29 '21 at 09:38
-
@WesleyRanger see my answer on a similar question: https://stackoverflow.com/a/72999525/9196664 – Imran Said Jul 21 '22 at 16:01
2
Please using Freeze command and you will get text file with all the versions of packages. Then install them using easy install or pip install

Abin Abraham
- 497
- 2
- 11
- 26