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/

  

python环境的导入与导出

导出命令为:pip freeze > requirements.txt

在新环境下安装移植项目依赖的三方库方法为:pip install -r requirements.txt

posted @ 2019-02-14 22:04  -零  阅读(513)  评论(0编辑  收藏  举报