35

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?

Prashant Kumar
  • 20,069
  • 14
  • 47
  • 63
sammydc
  • 514
  • 1
  • 4
  • 12

3 Answers3

33

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.

llimllib
  • 3,642
  • 1
  • 29
  • 29
11

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.

alif
  • 619
  • 1
  • 6
  • 10
  • 1
    Now, a couple of years later, see http://stackoverflow.com/a/14753678/260122 for a great overview of the packaging tool situation on Python. – clacke Mar 12 '15 at 14:27
  • 2
    Also, look into `virtualenv` and Python 3.x's native `venv`, they are the recommended method for predictability and isolation from what packages happen to be installed in your system. – clacke Mar 12 '15 at 14:30
  • For even better information, kept up-to-date, there's now https://python-packaging-user-guide.readthedocs.org/en/latest/current/ . (/via http://stackoverflow.com/questions/6344076/differences-between-distribute-distutils-setuptools-and-distutils2/14753678#comment25440872_14753678 ) – clacke Nov 03 '15 at 09:50
2

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.

denis
  • 21,378
  • 10
  • 65
  • 88