21
votes

My scenario is I have two laptops with fresh installation of windows. Now I use both of them for programming.

So, lets suppose I install various python modules/packages in one of the laptop. So is there a way I can clone this complete python setup on my other laptop. The reason for this is my internet connection currently is very slow so I don't want to download the same module or packages twice and than install them again.

I know I can download the modules in zip file, transfer them on other and than run python setup.py install but I am going to use pip to install modules.

Anyways, I was wondering if cloning of python setup is possible.

4

4 Answers

33
votes

Here is a completely different suggestion, this is recommended if you want to synchronize the packages between the two PCs and not cloning everything just once.

It only works if you install packages with pip. It does not work for packages which are not installable/installed with pip.

  1. Set up the pip cache to a network storage / USB stick which is accessible from both PCs (see https://stackoverflow.com/a/4806458/851737 for instructions)
  2. Freeze your current package environment from the source PC into a requirements file:

    $ pip freeze > req.txt

  3. Copy the req file to the target PC and install the packages:

    $ pip install -r req.txt

If you put the req.txt under a VCS you can automate and synchronize this process very smoothly.

11
votes

If you have the same Python version on both PCs, you can just copy the content of Lib\site-packages and Scripts to the new one. But note that it must be the same minor version (e.g. 2.6 does not work with 2.7).

4
votes

If you use a virtualenv (http://www.virtualenv.org) you should be able to store that on a USB-stick and carry it with you.

1
votes

I was updating Python 2.7.3 --> 2.7.9 on my Windows 7 PC. Normally this would be fine however the new install accidentally went onto the C: instead of where my previous version of python was located, on the D: drive. To get it to work was simply a matter of copying the new install straight over the top of the old. Worked like a charm and all my old modules that I had installed were present.