方法1:新增conda虚拟环境
1. 在有外网的环境下准备需要的python环境
conda create --name your_env_names python=3.x.x
2. 下载并安装第三方库
pip install 包名 --index https://mirrors.ustc.edu.cn/pypi/web/simple/
安装过程中添加清华镜像加速安装过程 --index https://mirrors.ustc.edu.cn/pypi/web/simple/
方法2:已有conda虚拟环境中安装新包
1. pip install 包名 --index https://mirrors.ustc.edu.cn/pypi/web/simple/
2. 查看新增加包的相关依赖
提前安装好pipdeptree,查看包的依赖
pipdeptree -p 新增加包名 -f
eg:查看pandas的依赖
pipdeptree -p pandas -f
pandas==1.0.3
numpy==1.19.0
python-dateutil==2.8.2
six==1.16.0
pytz==2022.5
3. 新建requirements.txt
把安装包及相关requirements.txt
4. 下载对应的whl包
pip download -d packages -r requirements.txt --index https://mirrors.ustc.edu.cn/pypi/web/simple/
5. 基于requirements.txt和packages安装
pip install --no-cache-dir --no-index --find-links=packages -r requirements.txt