欢迎来到小飞的博客

向前跑,迎着冷眼和嘲笑,生命的广阔不历经磨难怎能感到 命运它无法让我们跪地求饶 就算鲜血洒满了怀抱 继续跑 带着赤子的骄傲 生命的闪耀不坚持到底怎能看到 与其苟延残喘不如纵情燃烧吧。
扩大
缩小

【anaconda软件】Anaconda使用教程全攻略---pip安装和使用(十二)

一、pip安装

 暂略

二、pip常用命令

1、显示版本和路径

pip --version

 2、获取帮助

pip --help

 3.升级 pip

pip install -U pip

4.安装资源包

pip install SomePackage              # 最新版本
pip install SomePackage==1.0.4       # 指定版本
pip install 'SomePackage>=1.0.4'     # 最小版本

可以通过使用==, >=, <=, >, < 来指定一个版本号

5.升级包

pip install --upgrade SomePackage

升级指定的包,通过使用==, >=, <=, >, < 来指定一个版本号。

6.卸载包

pip uninstall SomePackage

7.搜索包

pip search Django

8.显示安装包信息

pip show 

9.查看指定包的详细信息

pip show -f SomePackage

 1  (py38_office) C:\Windows\System32>pip show -f pillow
 2   Name: Pillow          #   库名称    
 3   Version: 9.3.0         #  库版本
 4  Summary: Python Imaging Library (Fork)        # 摘要
 5  Home-page: https://python-pillow.org          # 主页
 6  Author: Alex Clark (PIL Fork Author)          # 作者
 7  Author-email: aclark@python-pillow.org        # 作者邮箱
 8  License: HPND          #  许可证
 9  Location:              #  安装位置
10 d:\languagedevelopment\anaconda3\envs\py38_office\lib\site-packages
11 Requires:                                                          #  需要依赖的包
12 Required-by: filestools, imageio, matplotlib, pikepdf, poimage, python-pptx, reportlab, wordcloud    #  被依赖的包
13 Files:
14     PIL\BdfFontFile.py
15     PIL\BlpImagePlugin.py 
16     PIL\BmpImagePlugin.py
17 ............

Requires 和 Required-by 两个属性分别表示 request 要依赖和被依赖的包情况;

pillow:被以下这些包所依赖:filestools, imageio, matplotlib, pikepdf, poimage, python-pptx, reportlab, wordcloud
pillow:不需要依赖其他包:

10.列出已安装的包

pip list

11.查看可升级的包

pip list -o

12.pip 升级

  • Linux 或 macOS
 pip install --upgrade pip    # python2.x
 pip3 install --upgrade pip   # python3.x
  • Windows 平台升级:
python -m pip install -U pip   # python2.x
python -m pip3 install -U pip    # python3.x
  • pip 清华大学开源软件镜像站:

使用国内镜像速度会快很多:

临时使用:

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

例如,安装 Django:

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

如果要设为默认需要升级 pip 到最新的版本 (>=10.0.0) 后进行配置:

pip install pip -U
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

如果您到 pip 默认源的网络连接较差,临时使用本镜像站来升级 pip:

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

13.注意事项

如果 Python2 和 Python3 同时有 pip,则使用方法如下:

  • Python2:
python2 -m pip install XXX
  • Python3:
python3 -m pip install XXX

 14.查看当前pip源

pip config list

 15.配置多个pip源

直接在user目录中创建一个pip目录,如:C:\Users\xx\pip,新建文件pip.ini

 1 [global]
 2 index-url=http://pypi.douban.com/simple  # 豆瓣源()
 3 extra-index-url=
 4     http://mirrors.aliyun.com/pypi/simple/  # 阿里云
 5     https://pypi.tuna.tsinghua.edu.cn/simple/  # 清华源
 6     http://pypi.mirrors.ustc.edu.cn/simple/   # 中科大源
 7 
 8 [install]
 9 trusted-host=
10     pypi.douban.com
11     mirrors.aliyun.com
12     pypi.tuna.tsinghua.edu.cn
13     pypi.mirrors.ustc.edu.cn

先从index-url查找,找不到则从extra-index-url查找

采用   pip config list 查看所有源

 下载链接:https://files.cnblogs.com/files/xf23554/pip%E6%BA%90.zip

参考文章:

posted on 2021-02-05 15:56  开发小飞  阅读(1730)  评论(0编辑  收藏  举报

导航