Linux下安装pip

Linux下安装pip

安装pip

wget https://bootstrap.pypa.io/get-pip.py
python get-pip.py
pip -V  #查看pip版本

配置pip源

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

pip install markdown -i https://pypi.tuna.tsinghua.edu.cn/simple

这样我们就从清华大学源成功安装了markdown模块,速度会比过pip默认的国外源快很多。

上述做法是临时改成国内源,如果不想每次用 pip 都加上 -i ,那么可以把国内源设为默认,做法是:

# 清华源
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://www.cnblogs.com/-wenli/p/10381026.html