Python是否具有程序包/模块管理系统? [英] Does Python have a package/module management system?

查看:87
本文介绍了Python是否具有程序包/模块管理系统?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Python是否具有程序包/模块管理系统,类似于Ruby具有可以在其中执行gem install packagename的rubygems的方式?

Does Python have a package/module management system, similar to how Ruby has rubygems where you can do gem install packagename?

安装Python模块 上,我仅看到参考到python setup.py install,但这要求您先找到该软件包.

On Installing Python Modules, I only see references to python setup.py install, but that requires you to find the package first.

推荐答案

最近的进度

2014年3月:好消息! Python 3.4 随Pip一起提供. Pip长期以来一直是Python的事实上的标准包管理器.您可以像这样安装软件包:

Recent progress

March 2014: Good news! Python 3.4 ships with Pip. Pip has long been Python's de-facto standard package manager. You can install a package like this:

pip install httpie

哇!这是所有Python版本中的最佳功能.它使每个人都可以访问社区丰富的图书馆.新手不再因设置的困难而无法使用社区库.

Wahey! This is the best feature of any Python release. It makes the community's wealth of libraries accessible to everyone. Newbies are no longer excluded from using community libraries by the prohibitive difficulty of setup.

但是,对于Python打包体验仍然有许多令人沮丧的地方.累积地,它们使Python对新手来说非常不受欢迎.此外,长期的忽视历史(即从Python 2.0到Python 3.3一直没有使用包管理器交付14年)确实对社区造成了损害.我在下面都介绍.

However, there remains a number of outstanding frustrations with the Python packaging experience. Cumulatively, they make Python very unwelcoming for newbies. Also, the long history of neglect (ie. not shipping with a package manager for 14 years from Python 2.0 to Python 3.3) did damage to the community. I describe both below.

重要的是要理解,尽管经验丰富的用户能够解决这些问题,但它们却成为了Python新手的重大障碍.实际上,困难和普遍的用户不友好可能阻止了其中许多人.

It's important to understand that while experienced users are able to work around these frustrations, they are significant barriers to people new to Python. In fact, the difficulty and general user-unfriendliness is likely to deter many of them.

每种带有程序包管理器的语言都有一个官方(或准官方)存储库,供社区下载和发布程序包. Python具有Python包索引PyPI. https://pypi.python.org/pypi

Every language with a package manager has an official (or quasi-official) repository for the community to download and publish packages. Python has the Python Package Index, PyPI. https://pypi.python.org/pypi

让我们将其页面与RubyGems和Npm(节点程序包管理器)的页面进行比较.

Let's compare its pages with those of RubyGems and Npm (the Node package manager).

  1. 包的页面rails https://rubygems.org/gems/rails RubyGems页面
  2. https://www.npmjs.org/package/express 软件包的Npm页面express
  3. https://pypi.python.org/pypi/simplejson/的PyPI页面包simplejson
  1. https://rubygems.org/gems/rails RubyGems page for the package rails
  2. https://www.npmjs.org/package/express Npm page for the package express
  3. https://pypi.python.org/pypi/simplejson/ PyPI page for the package simplejson

您将看到RubyGems和Npm页面均以该程序包的单行描述开头,然后是如何安装的大型友好说明.

You'll see the RubyGems and Npm pages both begin with a one-line description of the package, then large friendly instructions how to install it.

同时,天真地浏览到PyPI的所有不幸的Python用户也会感到困扰.在 https://pypi.python.org/pypi/simplejson/上,他们会找到没有这样有用的指示.但是,有一个绿色的大下载"链接.遵循它并非没有道理.啊哈,他们点击!他们的浏览器下载.tar.gz文件.许多Windows用户甚至无法打开它,但是如果他们坚持不懈,他们最终可能会提取它,然后运行setup.py并最终在Google setup.py install的帮助下运行.有些人会放弃并重新发明轮子.

Meanwhile, woe to any hapless Python user who naively browses to PyPI. On https://pypi.python.org/pypi/simplejson/ , they'll find no such helpful instructions. There is however, a large green 'Download' link. It's not unreasonable to follow it. Aha, they click! Their browser downloads a .tar.gz file. Many Windows users can't even open it, but if they persevere they may eventually extract it, then run setup.py and eventually with the help of Google setup.py install. Some will give up and reinvent the wheel..

当然,所有这些都是错误的. 最简单的安装软件包的方法是使用Pip命令.但是PyPI甚至没有提到Pip.相反,它引导他们走下了一条古老而乏味的道路.

Of course, all of this is wrong. The easiest way to install a package is with a Pip command. But PyPI didn't even mention Pip. Instead, it led them down an archaic and tedious path.

Numpy是Python最受欢迎的库之一.尝试使用Pip安装它,您会收到以下神秘错误消息:

Numpy is one of Python's most popular libraries. Try to install it with Pip, you get this cryptic error message:

错误:找不到vcvarsall.bat

Error: Unable to find vcvarsall.bat

试图解决这一问题,这是堆栈溢出中最受欢迎的问题之一:"错误:找不到vcvarsall.bat "

Trying to fix that is one of the most popular questions on Stack Overflow: "error: Unable to find vcvarsall.bat"

很少有人能成功.

为进行比较,在相同情况下,Ruby打印此消息,该消息说明了正在发生的事情以及如何解决此问题:

For comparison, in the same situation, Ruby prints this message, which explains what's going on and how to fix it:

请更新您的PATH以包括构建工具,或从 http://rubyinstaller.org/downloads 下载DevKit.并按照 http://github.com/oneclick/rubyinstaller/wiki/Development-工具包

Please update your PATH to include build tools or download the DevKit from http://rubyinstaller.org/downloads and follow the instructions at http://github.com/oneclick/rubyinstaller/wiki/Development-Kit

发布程序包很困难

Ruby和Nodejs随附功能齐全的软件包管理器Gem(自2007年起)和Npm(自2011年起),并培育了以GitHub为中心的共享社区. Npm使发布软件包就像安装它们一样容易,它已经具有 72k软件包.古老的Python软件包索引仅列出 41k .

Publishing packages is hard

Ruby and Nodejs ship with full-featured package managers, Gem (since 2007) and Npm (since 2011), and have nurtured sharing communities centred around GitHub. Npm makes publishing packages as easy as installing them, it already has 64k packages. RubyGems lists 72k packages. The venerable Python package index lists only 41k.

面对"附带的电池"的座右铭,Python一直没有包装管理器发货,直到2014.

Flying in the face of its "batteries included" motto, Python shipped without a package manager until 2014.

直到Pip为止,事实上的标准是命令easy_install.真是太糟糕了.没有用于卸载软件包的命令.

Until Pip, the de facto standard was a command easy_install. It was woefully inadequate. The was no command to uninstall packages.

点数是一个巨大的进步.它具有Ruby's Gem的大多数功能.不幸的是,直到最近,Pip一直很难安装.实际上,问题仍然是Stack Overflow上的一个Python首要问题:"如何安装pip在Windows上?"

Pip was a massive improvement. It had most the features of Ruby's Gem. Unfortunately, Pip was--until recently--ironically difficult to install. In fact, the problem remains a top Python question on Stack Overflow: "How do I install pip on Windows?"

这篇关于Python是否具有程序包/模块管理系统?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆