How to List Python Packages for Backup and Sync
Before I go into the details, I do want to clarify one thing: depending on how you would to set it up, (e.g. one machine doesn’t have internet connection, or one machine needs to have exact environment as the other) there are numerous ways to handle this. The one I am describing is simply an easy way to install the same packages from pip, and the same versions of the pip. If you have specific requirements, I suggest looking into those options as well, as Python community likely supports it as well.
Instructions
Let’s start with the case where both machines would have access to the internet. This method does not guarantee both machines would run identical version of the packages.
- From primary machine (one with all the packages installed):
pip freeze > requirements.txt
- To secondary machines (ones need packages to be installed)
pip install -r requirements.txt
For cases where secondary machines don’t have access to the internet, you could try downloading packages using pip from the primary using pip download
, then installing it via pip install
. There are other more sophisticated tools as well, it’s a bit of rabbit hole. I’ve used pip in this example, because most Python users would use pip regardless of the situations.