Move all Python packages to new computer (same versions)

Question:

I need to mirror all my Python settings and modules on Computer A vs Computer B.

I could list all packages/modules in computer A using pip list and then install them on computer B one by one – but there are literally ~ 100s of packages.

Is there a better/quicker way to achieve this?

In addition:

1) When overwriting previous installations, for example, do I have to use pip install --force-reinstall "pandas==0.23.0"?

2) Is there a way to exclude selected packages (some personal, redundant modules)?

Both machines are Windows and run the same Python version.

Asked By: EStark

||

Answers:

On the old system

pip freeze >frozen.txt

Then copy the output file to the destination system and

pip install -r frozen.txt

You can’t have both detailed control and quick convenience; if you want more control, manually prune the file before installing the packages.

A common convention is to manually add the packages which your code directly depends on to a file called requirements.txt; then just run pip install -r requirements.txt on the destination system.

Rather than have an endlessly raging battle between packages with different and possibly conflicting requirements, explore using a virtual environment for each.

Answered By: tripleee
Categories: questions Tags:
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.