在內(nèi)網(wǎng)環(huán)境只能本地方式安裝需要的包葵萎,需要在公網(wǎng)機器上下載需要的包及相應依賴包嗡害,傳輸至內(nèi)網(wǎng)進行安裝支鸡。以win10系統(tǒng)python 3.7.3為例:
安裝pipdeptree:
PS D:\test> pip install pipdeptree
假如想在內(nèi)網(wǎng)安裝flask鼠渺,先在外網(wǎng)下載安裝:
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文件夾拷貝至內(nèi)網(wǎng)機器(如F:/test)湾盗,進入test目錄執(zhí)行如下命令離線安裝
PS F:\test> pip install --no-index --find-links=./ -r requirements.txt