7

I downloaded some packages in my environment using pip command. And I want to have a copy of them to transfer them to another environment. I know that using:

pip freeze > requirements.txt

will generate requirements into a file, but since my second environment does not have access to internet i can not use:

pip install -r requirements.txt

to install that packages again. Is there any way to copy installed packages? or somehow install packages in a specified directory in my first environment? Thanks

  • [pipdeptree](https://pypi.org/project/pipdeptree/) is great for determining what packages *you* installed (without listing the dependencies). – idbrii Apr 10 '23 at 15:33

1 Answers1

12

You can use pip download followed by pip install --find-links to achieve what you want.Here is the steps involved

  1. Get the requirements

pip freeze>requirements.txt

  1. Download the packages to a folder
pip download -r requirements.txt -d path_to_the_folder
  1. From the new environment

pip install -r requirements.txt --find-links=path_to_the_folder

Jose Cherian
  • 7,207
  • 3
  • 36
  • 39