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 源。
- 创建配置文件
~/.pip/pip.conf
- 在文件中写入如下配置:
[global]
index-url = http://pypi.douban.com/simple
[install]
trusted-host = pypi.douban.com
- 使用 pip install ddt 安装依赖包
网友评论