How to migrate a python site to another machine?

django, python, virtualenv

Solution

In case you are using `pip` for package management, you can easily recreate the virtualenv on another system:

On system1, run `pip freeze --local > requirements.txt` and copy that file to system2. Over there, create and activate the virtualenv and use `pip install -r requirements.txt` to install all packages that were installed in the previous virtualenv.

Your python code can be simply copied to the new system; I'd `find -name '*.pyc' -delete` though since you usually do not want to move compiled code (even if it's just python bytecode) between machines.

Problem

I would like to know how to setup a complex python website, that is currently running in production environment, into a local machine for development? Currently the site uses python combined with Django apps (registration + cms modules) in a virtual environment.

Original source