Where are the python modules stored?

morpheous picture morpheous · May 28, 2010 · Viewed 222.7k times · Source

I have recently started learning Python and I have 2 questions relating to modules.

  1. Is there a way to obtain a list of Python modules available (i.e. installed) on a machine?
  2. I am using Ubuntu Karmic and Synaptic for package management. I have just installed a python module.Where is the module code actually stored on my machine? (is there a default [recommended] location that modules are stored)?

Answer

Xavier Ho picture Xavier Ho · May 28, 2010

1) Is there a way to obtain a list of Python modules available (i.e. installed) on a mchine?

This works for me:

help('modules')

.

2) Where is the module code actually stored on my machine?

Usually in /lib/site-packages in your Python folder. (At least, on Windows.)

You can use sys.path to find out what directories are searched for modules.