对于 Python 程序员来说,有什么等同于 Perl 的 CPAN 的吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/410163/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
For Python programmers, is there anything equivalent to Perl's CPAN?
提问by sammydc
I'm learning Python now because of the Django framework. I have been a Perl programmer for a number of years and I'm so used to Perl's tools. One of the things that I really miss is Perl's CPAN and its tools. Is there anything equivalent in Python? I would like to be able to search, install and maintain Python modules as easy as CPAN. Also, a system that can handle dependencies automatically. I tried to install a module in Python by downloading a zip file from a website, unzipped it, then do:
由于 Django 框架,我现在正在学习 Python。我当 Perl 程序员已经很多年了,我已经非常习惯 Perl 的工具了。我真正怀念的一件事是 Perl 的 CPAN 及其工具。Python中有什么等价的吗?我希望能够像 CPAN 一样轻松地搜索、安装和维护 Python 模块。此外,一个可以自动处理依赖关系的系统。我试图通过从网站下载一个 zip 文件来在 Python 中安装一个模块,解压缩它,然后执行以下操作:
sudo python setup.py install
sudo python setup.py install
but it's looking for another module. Now, lazy as I am, I don't like chasing dependencies and such, is there an easy way?
但它正在寻找另一个模块。现在,虽然我很懒,但我不喜欢追逐依赖等,有什么简单的方法吗?
采纳答案by llimllib
sammy, have a look at pip, which will let you do "pip install foo", and will download and install its dependencies (as long as they're on PyPI). There's also EasyInstall, but pip is intended to replace that.
sammy,看看pip,它会让你做“pip install foo”,并且会下载并安装它的依赖项(只要它们在PyPI 上)。还有EasyInstall,但 pip 旨在取代它。
回答by alif
It might be useful to note that pip and easy_install both use the Python Package Index (PyPI), sometimes called the "Cheeseshop", to search for packages. Easy_install is currently the most universally supported, as it works with both setuptools and distutils style packaging, completely. See James Bennett's commentaryon python packaging for good reasons to use pip, and Ian Bicking's replyfor some clarifications on the differences.
需要注意的是 pip 和 easy_install 都使用Python Package Index (PyPI),有时称为“Cheeseshop”来搜索包。Easy_install 目前是最受支持的,因为它完全适用于 setuptools 和 distutils 风格的包装。有关使用 pip 的充分理由,请参阅James Bennett对 python 包装的评论,以及Ian Bicking对差异的一些澄清的回复。
回答by denis
If you do use easy_install
, I'd suggest installing packages by doing..
如果您确实使用easy_install
,我建议您通过以下方式安装软件包...
easy_install -v -Z package_name | tee date-package.log
-Z
(short for --always-unzip
) unzips the .egg
files to directories so you can then..
-Z
(简称--always-unzip
)将.egg
文件解压缩到目录中,这样您就可以..
less *.egg/EGG-INFO/requires.txt
less *.egg/EGG-INFO/PKG-INFO
egrep '^(Name|Version|Sum|...)' *.egg/EGG-INFO/PKG-INFO
On Sammy's original question, a couple of package indexes other than PyPI are:
Scipyand Scipy docsfor scientific computing
ohlohwith code metrics.
在 Sammy 的原始问题上,PyPI 之外的几个包索引是:
Scipy和Scipy docsfor
sciencecomputing ohlohwith code metrics。