当前位置:Gxlcms > Python > Python安装第三方库的3种方法

Python安装第三方库的3种方法

时间:2021-07-01 10:21:17 帮助过:107人阅读

【方法一】: 通过setuptools来安装python模块

首先下载 http://peak.telecommunity.com/dist/ez_setup.py

NOTE: 最好下载个setuptools,本人是15.2版本,里面包含了ez_setup

运行 python ez_setup.py

  1. D:\work\installation\setuptools-15.2\setuptools-15.2>python ez_setup.py > 1.txt
  2. Extracting in c:\users\admini~1\appdata\local\temp\tmpbxikxf
  3. Now working in c:\users\admini~1\appdata\local\temp\tmpbxikxf\setuptools-15.2
  4. Installing Setuptools
  5. ......
  6. Copying setuptools-15.2-py2.7.egg to c:\python27\lib\site-packages
  7. setuptools 15.2 is already the active version in easy-install.pth
  8. Installing easy_install-script.py script to C:\Python27\Scripts
  9. Installing easy_install.exe script to C:\Python27\Scripts
  10. Installing easy_install-2.7-script.py script to C:\Python27\Scripts
  11. Installing easy_install-2.7.exe script to C:\Python27\Scripts
  12. Installed c:\python27\lib\site-packages\setuptools-15.2-py2.7.egg
  13. Processing dependencies for setuptools==15.2
  14. Finished processing dependencies for setuptools==15.2

运行 easy_install py

  1. D:\work>easy_install py #py 为第三方库文件
  2. Searching for py
  3. Best match: py 1.4.26
  4. Adding py 1.4.26 to easy-install.pth file
  5. Using c:\python27\lib\site-packages
  6. Processing dependencies for py
  7. Finished processing dependencies for py

【方法二】: 通过pip来安装python模块

安装 easy_install pip

  1. D:\work>easy_install pip
  2. Searching for pip
  3. Best match: pip 6.1.1
  4. Processing pip-6.1.1-py2.7.egg
  5. pip 6.1.1 is already the active version in easy-install.pth
  6. Installing pip-script.py script to C:\Python27\Scripts
  7. Installing pip.exe script to C:\Python27\Scripts
  8. Installing pip2.7-script.py script to C:\Python27\Scripts
  9. Installing pip2.7.exe script to C:\Python27\Scripts
  10. Installing pip2-script.py script to C:\Python27\Scripts
  11. Installing pip2.exe script to C:\Python27\Scripts
  12. Using c:\python27\lib\site-packages\pip-6.1.1-py2.7.egg
  13. Processing dependencies for pip
  14. Finished processing dependencies for pip

运行 pip install xlrd

  1. Usage:
  2. pip <command></command> [options]
  3. Commands:
  4. install Install packages.
  5. uninstall Uninstall packages.
  6. freeze Output installed packages in requirements format.
  7. list List installed packages.
  8. show Show information about installed packages.
  9. search Search PyPI for packages.
  10. wheel Build wheels from your requirements.
  11. zip DEPRECATED. Zip individual packages.
  12. unzip DEPRECATED. Unzip individual packages.
  13. help Show help for commands.
  14. General Options:
  15. -h, --help Show help.
  16. --isolated Run pip in an isolated mode, ignoring
  17. environment variables and user configuration.
  18. -v, --verbose Give more output. Option is additive, and can be
  19. used up to 3 times.
  20. -V, --version Show version and exit.
  21. -q, --quiet Give less output.
  22. --log <path> Path to a verbose appending log.
  23. --proxy <proxy> Specify a proxy in the form
  24. [user:passwd@]proxy.server:port.
  25. --retries <retries> Maximum number of retries each connection should
  26. attempt (default 5 times).
  27. --timeout <sec> Set the socket timeout (default 15 seconds).
  28. --exists-action Default action when a path already exists:
  29. (s)witch, (i)gnore, (w)ipe, (b)ackup.
  30. --trusted-host <hostname> Mark this host as trusted, even though it does
  31. not have valid or any HTTPS.
  32. --cert <path> Path to alternate CA bundle.
  33. --client-cert <path> Path to SSL client certificate, a single file
  34. containing the private key and the certificate
  35. in PEM format.
  36. --cache-dir <dir> Store the cache data in <dir>.
  37. --no-cache-dir Disable the cache.
  38. --disable-pip-version-check
  39. Don't periodically check PyPI to determine
  40. whether a new version of pip is available for
  41. download. Implied with --no-index.
  42. </dir></dir></path></path></hostname></sec></retries></proxy></path>

【方法三】:直接从网上下载下可执行文件来安装.

比如说,去 >>> pythonlibs <<< 网站,提供了很多Python非官方包下载,二进制文件,下载安装方便.

人气教程排行