- 普通安装
pip install package
- 安装在用户缓存中
pip install --user
- 去缓存安装
pip install --no-cache-dir packagename
"--no-cache-dir Disable the cache."
去缓存安装的目的,保证你更新代码时,不能将新的代码安装进去
- 国内源安装
国内源 自行百度
本次使用清华源安装
pip --default-timeout=1000 install --no-cache-dir packagename -i https://pypi.tuna.tsinghua.edu.cn/simple
--default-timeout=1000 设置超时时间 默认时长是15s 这此设置 1000s
- 从搭建的私有源安装
pip3 install --no-cache-dir packagename -i 服务地址 --trusted-host 服务地址中的ip
服务地址类似: https://pypi.tuna.tsinghua.edu.cn/simple 这个是清华源
- 指定依赖环境文件安装
pip install --no-cache-dir -i https://pypi.tuna.tsinghua.edu.cn/simple -r requirements.txt
- 指定依赖环境,并指定私有源
pip install --no-cache-dir -i 服务地址 -r requirements.txt --trusted-host 服务地址中的ip
- 指定以来环境文件及指定离线安装包
pip install -r requirements.txt --no-index --find-links 离线安装包路径
- 指定包的安装目录(当值安装在~/.local目录下)
pip install requests -t /opt/conda/envs/simple/lib/python3.6/site-packages/ -i https://pypi.tuna.tsinghua.edu.cn/simple/