在内网环境只能本地方式安装需要的包,需要在公网机器上下载需要的包及相应依赖包,传输至内网进行安装。以win10系统python 3.7.3为例:

安装pipdeptree:

PS D:\test> pip install pipdeptree

假如想在内网安装flask,先在外网下载安装:

PS D:\test> pip install flask

使用pipdeptree 查看并生成requirements.txt

PS D:\test> pipdeptree -f  -p flask
Flask==1.1.2
  click==7.1.2
  itsdangerous==1.1.0
  Jinja2==2.11.2
    MarkupSafe==1.1.1
  Werkzeug==1.0.1
PS D:\test> pipdeptree -f  -p flask > .\requirements.txt

下载所有包至本地

PS D:\test> pip download -r .\requirements.txt

将test文件夹拷贝至内网机器(如F:/test),进入test目录执行如下命令离线安装

PS F:\test> pip install --no-index --find-links=./ -r requirements.txt

转自:python 离线安装包及其依赖包 - 简书

评论




博客内容遵循 署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0) 协议

本站使用 Volantis 作为主题,总访问量为
载入天数...载入时分秒...
冀ICP备20001334号