pip download的使用记录


    实际开发中,我们的项目部署环境可能是封闭的内网环境,无法直接使用pip install -r requirement.txt这种方式安装项目依赖包,这时pip download这个犀利的工具就要发光发热了

1. 使用pip download在一个可以连接外网的环境下载整个项目的依赖包

pip download \
    --only-binary=:all: \ # 对于包以及包的依赖包,都不使用二进制
    --platform linux_x86_64 \  # 指定系统环境
    -d \home\packs   # 下载的文件的存储目录
    -r requirement.txt    # 指定要下载的包

 备注:实际使用中,会发现一些包找不到,比如tornado,会报错如下

ERROR: Could not find a version that satisfies the requirement tornado==6.0 (from -r src/requirements.txt (line 13)) (from versions: none)
ERROR: No matching distribution found for tornado==6.0 (from -r src/requirements.txt (line 13))

原因:没有提供符合条件的二进制包

解决方法:使用非二进制包安装   --no-binary=:all: package_name

pip download --no-binary=:all: tornado==6.0 -d pkg/

 

2. 使用这些下载好的包

sudo pip3 install -r /xxxx/xxxx/requirement.txt --no-index --find-links /xxxx/xxxxx/xxxxx/(存放下载好的包的目录)


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM