Python第三方库的安装

来自CloudWiki
Cloud17讨论 | 贡献2018年5月18日 (五) 09:14的版本
跳转至: 导航搜索

pip工具安装

  • 最常用且最高效的python第三方安装工具是采用pip工具安装。pip是python官方提供并维护的在线第三方库安装工具。对于同时安装python2和python3环境的系统,建议采用pip3命令专门为Python3版本安装第3方库。
  • pip是python内置命令,需要通过命令行执行。执行pip -h将列出她常用的字命令。
C:\Users\thinkpad>pip3 -h

Usage:
  pip <command> [options]

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.
  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.

[windows下面安装Python和pip终极教程 http://blog.csdn.net/lengqi0101/article/details/61921399]

[pip安装python库总是下载超时,有什么解决方法吗? http://segmentfault.com/q/1010000000162410]

安装库

  • 安装一个库的命令,格式如下:
pip3 install <拟安装库名>
  • 例子:
C:\Users\thinkpad>pip3 install pygame
Collecting pygame
  Downloading pygame-1.9.3-cp36-cp36m-win32.whl (4.0MB)
    5% |█▊                              | 215kB 28kB/s eta 0:02:11

查看已安装的库

  • pip3 list
C:\Users\thinkpad>pip3 list
DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.
pip (9.0.1)
pygame (1.9.3)
setuptools (28.8.0)

卸载已安装的库

  • pip3 uninstall pygame
 Proceed (y/n)? y
 Successfully uninstalled pygame-1.9.3