Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Transfer Python setup across different PC

Tags:

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.

like image 464
RanRag Avatar asked Jun 14 '12 13:06

RanRag


People also ask

How do I transfer python from one computer to another?

zip the contents of C:\python27 to an USB key. copy all python DLLS: copy C:\windows\system32\py*DLL K: (if K is your usb drive) unzip the contents of the archive somewhere on the second machine. add the DLLs directly in the python27 directory.

Where are Python packages installed?

When a package is installed globally, it's made available to all users that log into the system. Typically, that means Python and all packages will get installed to a directory under /usr/local/bin/ for a Unix-based system, or \Program Files\ for Windows.

Does PIP automatically install with Python?

PIP is automatically installed with Python 2.7.9+ and Python 3.4+ and it comes with the virtualenv and pyvenv virtual environments.


1 Answers

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.

like image 86
schlamar Avatar answered Oct 06 '22 07:10

schlamar