思路:在外网环境使用pip离线下载(不安装)依赖,然后上传到服务器再进行离线安装
下载:
使用 pip download 命令离线下载 requirements.txt 中列出的所有依赖包,而不安装它们:
代码语言:bash复制pip3 download --no-cache-dir --dest /path/to/downloaded_packages -r /requirements.txt参数解释:
--no-cache-dir: 禁用缓存。
--dest /path/to/downloaded_packages: 指定下载包的目标目录。
-r /requirements.txt: 指定包含依赖列表的文件。
安装:
使用 pip install 命令来安装所有依赖
代码语言:basic复制pip3 install --no-index --find-links=/whls -r /requirements.txt注意:/requirements.txt中的依赖和/whls 目录中的依赖要对应
参数解释:
--no-index: 禁用从 PyPI 索引中查找包。
--find-links=/whls: 指定查找包的目录。
-r /requirements.txt: 指定你的依赖文件,requirements.txt 中列出的所有包都会被安装
:


