PySe-013-指定安装源安装模块 + 修改安装源

使用 pip 安装模块的时候,pip 默认使用 Python 官方的镜像源,由于网络受限原因,经常会导致安装不可用。可通过使用国内的 Python 镜像源安装。常见的国内镜像源有如下几个,我比较习惯使用阿里的镜像源。

http://mirrors.aliyun.com/pypi/simple/ 阿里
http://pypi.douban.com/simple/ 豆瓣
http://pypi.hustunique.com/simple/ 华中理工大学
http://pypi.sdutlinux.org/simple/ 山东理工大学
http://pypi.mirrors.ustc.edu.cn/simple/ 中国科学技术大学

 

临时指定安装源:
pip install -i http://mirrors.aliyun.com/pypi/simple/ Django
pip install -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com Djang

 

Linux 更新 Python 镜像源配置文件路径:~/.pip/pip.conf
Windows 更新 Python 镜像源配置文件路径: C:\Users\电脑用户\AppData\Roaming\pip\pip.ini

在文件中添加如下所示的信息:
[global]
index-url = http://mirrors.aliyun.com/pypi/simple/

[install]
use-mirrors = true
mirrors = http://mirrors.aliyun.com/pypi/simple/
trusted-host = mirrors.aliyun.com

 

posted @ 2020-11-01 22:03  范丰平  Views(154)  Comments(0Edit  收藏  举报