Python离线安装项目所需所有pip包

1、查看已有的项目python所依赖的包列表

命令:

pip list

(注:如果是python3的环境,就用pip3 list)
效果:
Python离线安装项目所需所有pip包

2、存放pip对应版本包到指定文件夹

命令:

pip freeze > requirements.txt

效果:
Python离线安装项目所需所有pip包

3、下载对应版本包到当前文件夹

命令:

pip download -r requirements.txt --trusted-host mirrors.aliyun.com

效果:
Python离线安装项目所需所有pip包

4、离线安装

pip install --no-index --find-links=/home/packages -r requirements.txt 

注意:pip换源处理

如果有些包在一个源上找不到,不妨到其他源上去找找

pip install 包名 -i 源的URL

例如:

pip install scrapy -i https://pypi.tuna.tsinghua.edu.cn/simple

pip国内的一些镜像:
1、阿里云 http://mirrors.aliyun.com/pypi/simple/
2、中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/
3、豆瓣(douban) http://pypi.douban.com/simple/
4、清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/
5、中国科学技术大学 http://pypi.mirrors.ustc.edu.cn/simple/