简体   繁体   中英

For Python programmers, is there anything equivalent to Perl's CPAN?

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:

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?

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.

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 commentary on python packaging for good reasons to use pip, and Ian Bicking's reply for some clarifications on the differences.

If you do use easy_install , I'd suggest installing packages by doing..

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..

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:
Scipy and Scipy docs for scientific computing
ohloh with code metrics.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM