天天看点

00.python3:pip的使用方法

我使用的python 3.6.5自带pip,故不用再单独安装pip,pip在\Python36\Scripts目录下

1.使用py -3 -m pip 查询pip的使用命令:

py -3 -m pip
Commands:
  install                     Install packages.
  download                    Download packages.
  uninstall                   Uninstall packages.
  freeze                      Output installed packages in requirements format.
  list                        List installed packages.
  show                        Show information about installed packages.
  check                       Verify installed packages have compatible dependencies.
  config                      Manage local and global configuration.
  search                      Search PyPI for packages.
  wheel                       Build wheels from your requirements.
  hash                        Compute hashes of package archives.
  completion                  A helper command used for command completion.
  help                        Show help for commands.
           

2.常用的命令

1.pip install:py -3 -m pip install nose #安装
              py -3 -m pip install nose==1.3.0 #指定版本安装
2.pip install upgrade: py -3 -m pip install -U nose #升级
                       py -3 -m pip install --upgrade nose #升级
                       py -3 -m pip install -U pip  #pip升级
3.pip show:py -3 -m pip show nose #显示包所在目录及信息
4.pip uninstall:py -3 -m pip uninstall nose #卸载
5.pip list:py -3 -m pip list #查询安装的列表

6.pip search:pip search nose #搜索
7.pip freeze: #以需求格式输出已安装的包,如到requirements
具体使用方法:pip freeze | tee requirements.txt # 输出本地包环境至文件
8.pip install -r requirements.txt #安装requirements文件里的安装包
9.pip list -o #查询可升级的包

#通过对比pip freeze和pip list会发现输出的结果有差别
#所以,pip freeze 为什么比 pip list 的包少几个呢? 
因为pip , wheel , setuptools 等包,是自带的而无法(un)install的。
#考虑到pip freeze的用途,所以这些包并没有显示。
ps: 
如果一定要用pip freeze来显示所有包,可以加上参数-all,即pip freeze --all
           

10.download、config、wheel、hash、completion的功能我也不清楚,待查到后再做补充