Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
471 views
in Technique[技术] by (71.8m points)

python - Copy installed packages using pip to another environment

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...