Python第三方库批量下载到本地,并离线批量安装第三方库
鉴于公司内网安装的python版本为python3.6.5,而此时又需要安装第三方库pytest,本来是想直接在Python官网PyPI直接搜对应可匹配跑python3.6.5版本的pytest进行下载然后传到内网安装即可,但是发现pytest依赖别的第三方库,根据报错装了几个依赖的第三方库之后,发现还是一堆的问题,故索性在外网环境先安装一个python3.6.5版本的解释器,然后cmd命令行 pip install pytest,然后依据自动下载的第三方库,来确定python3.6.5安装推荐的pytest的版本以及pytest依赖的第三方库的名称及版本:pip install pytesthttps://img2023.cnblogs.com/blog/1435837/202306/1435837-20230605164338832-1091494449.png
https://img2023.cnblogs.com/blog/1435837/202306/1435837-20230605164430843-922194266.png
在桌面上新建个保存第三方库的目录:softwares,然后我这里将当前python3.6.5解释器安装的所有第三方库都导出输出到该目录下的requirements.txt中:
python -m pip freeze > requirements.txthttps://img2023.cnblogs.com/blog/1435837/202306/1435837-20230605171403663-1677955205.png
然后剔除当前pytest版本不需要的依赖,保留当前pytest所需要安装的所有第三方库名称及版本号:
https://img2023.cnblogs.com/blog/1435837/202306/1435837-20230605170806403-815857818.png
然后通过国内源下载上面统计的所需要的第三方库:
pip download -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple/https://img2023.cnblogs.com/blog/1435837/202306/1435837-20230605171716065-795326357.png
下载好了,之后将这些whl后缀的第三方库文件,传到内网,通过cmd直接 pip install xxx就可以啦。
https://img2023.cnblogs.com/blog/1435837/202306/1435837-20230605171830986-1489208728.png
批量安装本地安装包:
pip install --no-index --ignore-installed --find-links=C:/Users/SSCC/Desktop/softwares -r requirements.txt
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!
页:
[1]