Python 包下载 - douban 源

2020-03-11  本文已影响0人  风禾尽绮

python 默认使用国外源下载依赖包,经常会下载失败(例如报下面的错误),于是出现了以豆瓣为主的国内下载源。

Could not find a version that satisfies the requirement ddt (from versions: )
No matching distribution found for ddt

单次应用

pip install ddt -i http://pypi.douban.com/simple --trusted-host pypi.douban.com

配置文件应用

单次应用执行命令太长,可以通过配置文件的方式,设置所有要下载的包都使用 douban 源。

  1. 创建配置文件
~/.pip/pip.conf

  1. 在文件中写入如下配置:
[global]
index-url = http://pypi.douban.com/simple
[install]
trusted-host = pypi.douban.com
  1. 使用 pip install ddt 安装依赖包
上一篇下一篇

猜你喜欢

热点阅读