Python pip 修改源地址为国内源的方法

您所在的位置:网站首页 pip清华源 Python pip 修改源地址为国内源的方法

Python pip 修改源地址为国内源的方法

#Python pip 修改源地址为国内源的方法| 来源: 网络整理| 查看: 265

腾讯云 搬瓦工

最近在使用 pip 安装东西的时候发现速度特别慢,很多时候甚至还会安装失败,提示就是下载失败。于是搜了一下怎么替换 pip 的源,改为国内的源速度应该就会快很多了。本文记录一下 Python 的 pip 在使用过程中怎么修改源为国内源的方法。

文章目录 隐藏 一、Python pip 国内源地址整理 二、pip 临时使用国内源的方法 三、pip 永久修改国内源的方法 一、Python pip 国内源地址整理 pypi 清华大学源:https://pypi.tuna.tsinghua.edu.cn/simple pypi 豆瓣源 :http://pypi.douban.com/simple/ pypi 腾讯源:http://mirrors.cloud.tencent.com/pypi/simple pypi 阿里源:https://mirrors.aliyun.com/pypi/simple/ 二、pip 临时使用国内源的方法

pip 源具体修改方式是,我们以安装 Python 的 markdown 模块为例,通常的方式是直接在命令行运行

pip install markdown

这样会从国外官网下载 markdown 模块并安装。

若要把 pip 源换成国内的,只需要把上面的代码改成下图这样(下图以清华大学源为例):

pip install markdown -i https://pypi.tuna.tsinghua.edu.cn/simple 三、pip 永久修改国内源的方法

如果不想每次用 pip 都加上 -i https://pypi.tuna.tsinghua.edu.cn/simple,那么可以把国内源设为默认,做法是:

# 清华源 pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple # 或: # 阿里源 pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/ # 腾讯源 pip config set global.index-url http://mirrors.cloud.tencent.com/pypi/simple # 豆瓣源 pip config set global.index-url http://pypi.douban.com/simple/

参考:https://zhuanlan.zhihu.com/p/109939711



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3