“Python第三方库的安装”的版本间的差异

来自CloudWiki
跳转至: 导航搜索
文件安装
安装库
第33行: 第33行:
 
   Downloading pygame-1.9.3-cp36-cp36m-win32.whl (4.0MB)
 
   Downloading pygame-1.9.3-cp36-cp36m-win32.whl (4.0MB)
 
     5% |█▊                              | 215kB 28kB/s eta 0:02:11</nowiki>
 
     5% |█▊                              | 215kB 28kB/s eta 0:02:11</nowiki>
 +
 +
如果系统中安装了多个python版本,可使用下列命令指定安装的python版本,其中的参数t的值可以使用import sys;print(sys.path)来获取
 +
 +
pip3 install -t C:\\Users\\thinkpad\\AppData\\Local\\Programs\\Python\\Python37\\lib\\site-packages xlrd
  
 
===查看已安装的库===
 
===查看已安装的库===

2018年6月10日 (日) 14:15的版本

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

如果系统中安装了多个python版本,可使用下列命令指定安装的python版本,其中的参数t的值可以使用import sys;print(sys.path)来获取

pip3 install -t C:\\Users\\thinkpad\\AppData\\Local\\Programs\\Python\\Python37\\lib\\site-packages xlrd

查看已安装的库

  • 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

自定义安装

文件安装

当目标机器处于离线环境,无法使用pip在线安装时,可从下列网站下载对应的第三方库,并拷贝至目标机上。

https://www.lfd.uci.edu/~gohlke/pythonlibs/