Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
489 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 Reply

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...