How do I find out what Python libraries are installed on my Mac?

From the Python REPL (the command-line interpreter / Read-Eval-Print-Loop), type help("modules") to see a list of all your available libs.

Then to see functions within a module, do help("posix"), for example. If you haven't imported the library yet, you have to put quotes around the library's name.


For the web server, you can run the pydoc module that is included in the python distribution as a script:

python /path/to/pydoc.py -p 1234

where 1234 is the port you want the server to run at. You can then visit http://localhost:1234/ and browse the documentation.


Every standard python distribution has these libraries, which cover most of what you will need in a project.

In case you need to find out if a library exists at runtime, you do it like this

try:
    import ObscureModule
except ImportError:
    print "you need to install ObscureModule"
    sys.exit(1) # or something like that

Tags:

Python