【转载】Python包管理工具pip与easy_install

简介:

     初学 Python,总是提示缺少各种各样的 Python 包,于是了解了下 Python 的包安装管理工具:

1.setuptools 中的 easy_install (Download, build, install, upgrade, and uninstall Python packages -- easily!)

easy_install 是 setuptools 包里的一个命令,所以想使用 easy_install 就得安装 setuptools 。

①可以直接下载setuptools-0.6c11.win32-py2.7.exe文件安装

下载地址:http://pypi.python.org/pypi/setuptools

      安装完成之后在 Python 安装目录下的 Scripts 目录下就会有 easy_install.exe,将 Scripts 加到Path 变量里,就可以使用它来安装 Python 包了,只需要将包名作为参数,它就会自动到 Pypi 里去查找并安装,例如:

easy_install SQLObject

②通过下载 ez_setup.py 脚本安装 setuptools

脚本下载地址:http://peak.telecommunity.com/dist/ez_setup.py

      安装效果应该是和方法①是一样的(但是这里下载的是setuptools-0.6c11-py2.7.egg),不过根据官网的文档,对于 64 位的机器,只能使用第二种方式进行安装。

2.pip(a tool for installing and managing Python packages, a replacement for easy_install)

      pip 的安装需要 setuptools 或者 distribute 如果你使用的是 Python3.x 那么就只能使用distribute 因为 Python3.x 不支持 setuptools 。

可以通过脚本 get-pip.py 来安装 pip,脚本下载地址:

https://raw.github.com/pypa/pip/master/contrib/get-pip.py 

下载后执行即可安装 pip 。

      安装完成之后相关的命令程序,同样会放到 Python 安装路径下的 Scripts 目录下,然后就可以用如下方式安装相关的包:

pip install SomePackage

 

      据说 pip 是 easy_install 的替代品,初学 Python,体会得不够深刻,期待后期补充,下面是 pip官网上对 pip 与 easy_install 进行的比较

pip is meant to improve on easy_install. Some of the improvements:

  • All packages are downloaded before installation. Partially-completed installation doesn’t occur as a result.
  • Care is taken to present useful output on the console.
  • The reasons for actions are kept track of. For instance, if a package is being installed, pip keeps track of why that package was required.
  • Error messages should be useful.
  • The code is relatively concise and cohesive, making it easier to use programmatically.
  • Packages don’t have to be installed as egg archives, they can be installed flat (while keeping the egg metadata).
  • Native support for other version control systems (Git, Mercurial and Bazaar)
  • Uninstallation of packages.
  • Simple to define fixed sets of requirements and reliably reproduce a set of packages.

pip doesn’t do everything that easy_install does. Specifically:

  • It cannot install from eggs. It only installs from source. (In the future it would be good if it could install binaries from Windows .exe or .msi – binary install on other platforms is not a priority.)
  • It is incompatible with some packages that extensively customize distutils or setuptools in their setup.py files.

pip is complementary with virtualenv, and it is encouraged that you use virtualenv to isolate your installation.


目录
相关文章
|
6月前
|
存储 缓存 测试技术
理解Python装饰器:简化代码的强大工具
理解Python装饰器:简化代码的强大工具
|
7月前
|
程序员 测试技术 开发者
Python装饰器:简化代码的强大工具
Python装饰器:简化代码的强大工具
282 92
|
6月前
|
异构计算 Python
ERROR: pip’s dependency resolver does not currently take into 报错-Python项目依赖冲突的解决方案-优雅草优雅草卓伊凡
ERROR: pip’s dependency resolver does not currently take into 报错-Python项目依赖冲突的解决方案-优雅草优雅草卓伊凡
496 1
|
6月前
|
机器学习/深度学习 编解码 Python
Python图片上采样工具 - RealESRGANer
Real-ESRGAN基于深度学习实现图像超分辨率放大,有效改善传统PIL缩放的模糊问题。支持多种模型版本,推荐使用魔搭社区提供的预训练模型,适用于将小图高质量放大至大图,放大倍率越低效果越佳。
476 3
|
6月前
|
人工智能 Shell Python
ERROR: pip’s dependency resolver does not currently take into 报错-Python项目依赖冲突的解决方案-优雅草优雅草卓伊凡
ERROR: pip’s dependency resolver does not currently take into 报错-Python项目依赖冲突的解决方案-优雅草优雅草卓伊凡
293 0
|
7月前
|
人工智能 自然语言处理 安全
Python构建MCP服务器:从工具封装到AI集成的全流程实践
MCP协议为AI提供标准化工具调用接口,助力模型高效操作现实世界。
1285 1
|
6月前
|
算法 安全 数据安全/隐私保护
Python随机数函数全解析:5个核心工具的实战指南
Python的random模块不仅包含基础的随机数生成函数,还提供了如randint()、choice()、shuffle()和sample()等实用工具,适用于游戏开发、密码学、统计模拟等多个领域。本文深入解析这些函数的用法、底层原理及最佳实践,帮助开发者高效利用随机数,提升代码质量与安全性。
1052 0
|
7月前
|
API 数据安全/隐私保护 Python
拼多多批量上架软件, 电商一键上货发布工具,python电商框架分享
多线程批量上传架构,支持并发处理商品数据 完整的拼多多API签名和token管理机制
|
Python
pip批量安装Python库 requirement.txt 离线环境无互联网环境下pip安装Python库
pip批量安装Python库 requirement.txt 离线环境无互联网环境下pip安装Python库
1234 3
|
自然语言处理 搜索推荐 程序员
【Python】如何使用pip,安装第三方库和生成二维码、操作Excel
【Python】如何使用pip,安装第三方库和生成二维码、操作Excel
386 0

热门文章

最新文章

推荐镜像

更多