Python 包下载 - douban 源

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 安装依赖包
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容