pip原理及常用命令

1、pip帮助文档

pip documentation

2、pip命令帮助

pip --help 或 pip

3、常用命令

pip install SomePackage              # 最新版本
pip install SomePackage==1.0.4       # 指定版本
pip install 'SomePackage>=1.0.4'     # 最小版本
 
pip install -i https://pypi.douban.com/simple SomePackage   # --index-url  可简写为 -i
pip install --index-url https://pypi.douban.com/simple SomePackage              
 
#extra-index-url用于声明备用源
#trusted-host用于声明放开对非https地址源的访问限制
pip install SomePackage -i http://mirrors.aliyun.com/pypi/simple/ 
    --extra-index-url https://pypi.python.org/simple
    --trusted-host mirrors.aliyun.com
 
pip install --extra-index-url https://pypi.douban.com/simple SomePackage #指定源安装
 
pip install -r requirements.txt
   Django==1.5.4
   MySQL-python>=1.2.3
 
pip install -e git+https://git.repo/some_pkg.git#egg=SomePackage      # 从 git 安装
pip install -e hg+https://hg.repo/some_pkg#egg=SomePackage            # 从 mercurial 安装
pip install -e svn+svn://svn.repo/some_pkg/trunk/#egg=SomePackage     # 从 svn 安装
pip install -e git+https://git.repo/some_pkg.git@feature#egg=SomePackage # 安装 branch
 
pip install ./downloads/SomePackage-1.0.4.tar.gz #安装本地安装包
 
#从包含安装包的本地目录搜索并安装(并且不检查PyPI索引)
pip install --no-index --find-links=file:///local/dir/ SomeProject
pip install --no-index --find-links=/local/dir/ SomeProject
pip install --no-index --find-links=relative/dir/ SomeProject
 
pip install --upgrade SomePackage
pip install -U  SomePackage   # --upgrade 可简写为 -U
pip install --upgrade pip   # pip升级自己
 
pip uninstall SomePackage
pip uninstall -r requirements.txt
 
pip freeze > requirements.txt
pip freeze > d:\requirements.txt #指定目录
 
pip list
pip show SomePackage
pip search SomePackage

 
4、pip更换国内源

临时使用: 
可以在使用pip的时候在后面加上-i参数,指定pip源  

pip install scrapy -i https://pypi.tuna.tsinghua.edu.cn/simple
永久更换:

linux: 
修改 ~/.pip/pip.conf (没有就创建一个), 内容如下:

[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
windows: 
直接在user目录中创建一个pip目录,如:C:\Users\xx\pip,新建文件pip.ini,内容如下

[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple

国内常用源:

(1)阿里云     https://mirrors.aliyun.com/pypi/simple/

(2)豆瓣     https://pypi.douban.com/simple/

(3)清华大学     https://pypi.tuna.tsinghua.edu.cn/simple/

(4)中国科学技术大学     https://pypi.mirrors.ustc.edu.cn/simple/

(5)华中科技大学  https://pypi.hustunique.com/

(6)网易: https://mirrors.163.com/pypi/simple
(7)华为:https://repo.huaweicloud.com/repository/pypi/simple
(8)腾讯:https://mirrors.cloud.tencent.com/pypi/simple

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值