tags:

views:

4246

answers:

2

I would like to get a list of Python modules, which are in my Python installation (UNIX server).

How can you get a list of Python modules installed in your computer?

A: 

From the shell

ls site-packages

If that's not helpful, you can do this.

import sys
import os
for p in sys.path:
    print os.listdir( p )

And see what that produces.

S.Lott
vezult
Also this will not show built-in modules, or modules in a custom PYTHONPATH, or ones installed in setuptools "development mode" etc.
dF
My /usr/local/lib/python2.5/site-packages is empty, although I have installed modules.
Masi
@dF: While true, I don't see how any of those alternatives are relevant to the question.
S.Lott
@Masi: Interesting. You'll have to look at sys.path to see all the places they might have been put.
S.Lott
+17  A: 
help('modules')

in a Python shell/prompt.

ChristopheD
I get such a warning: FutureWarning: apt API not stable yet warnings.warn("apt API not stable yet", FutureWarning). I did not get a list of Python modules. I am using Python 2.5.
Masi
Could you paste the entire warning at for example http://paste.pocoo.org and post the link here?
ChristopheD
“/usr/lib/python2.5/site-packages/apt/__init__.py:18: FutureWarning: apt API not stable yet” is normal on Debian/Ubuntu Pythons, an artefact of attempting to graft apt packages into Python package management. I still see the (textual) list of modules.
bobince
Also `pydoc modules` from the shell should work.
dF
@dF `pydoc modules` works. You should submit it as an answer.
Abizern
@Christopher: http://paste.pocoo.org/show/112078/
Masi
@dF: pydoc modules, gives me the exactly same output as in python shell: help('modules')
Masi
@Masi: matplotlib related problem according to http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=519965 Should be fixed in the latest version available from http://matplotlib.sourceforge.net/@Abizern: pydoc modules and help('modules') do the same thing...
ChristopheD
@ChristopheD: How can I see the version of my matplotlib? I tried import matplotlib; matplotlib --version unsuccessfully.
Masi