Where are the python modules stored?

Posted on

Question :

Where are the python modules stored?

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 #1:

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

This works for me:

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

Answered By: Xavier Ho

Answer #2:

On python command line, first import that module for which you need location.

import module_name

Then type:


For example to find out “pygal” location:

import pygal


Answered By: PanNik

Answer #3:

On Windows machine python modules are located at (system drive and python version may vary):

Answered By: Bhaskar Jagadeesha

Answer #4:

You can find module code by first listing the modules:


This spits out a list of modules Python can import. At the bottom of this list is a phrase:

Enter any module name to get more help. Or, type “modules spam” to
search for modules whose name or summary contain the string “spam”.

To find module location:


for example:


A lot of information here. Scroll to the bottom to find its location


Copy link. To see code, after exiting Python REPL:

nano /usr/lib/python3.5/signal.py
Answered By: user3424230

Answer #5:

  1. You can iterate through directories listed in sys.path to find all modules (except builtin ones).
  2. It’ll probably be somewhere around /usr/lib/pythonX.X/site-packages (again, see sys.path). And consider using native Python package management (via pip or easy_install, plus yolk) instead, packages in Linux distros-maintained repositories tend to be outdated.
Answered By: Cat Plus Plus

Answer #6:

If you are using conda or pip to install modules you can use

pip list


conda list

to display all the modules. This will display all the modules in the terminal itself and is much faster than

>>> help('modules')

Answered By: Trect

Answer #7:

1) Using the help function

Get into the python prompt and type the following command:


This will list all the modules installed in the system. You don’t need to install any additional packages to list them, but you need to manually search or filter the required module from the list.

2) Using pip freeze

sudo apt-get install python-pip
pip freeze

Even though you need to install additional packages to use this, this method allows you to easily search or filter the result with grep command. e.g. pip freeze | grep feed.

You can use whichever method is convenient for you.

Answered By: Abrar Ahmad

Leave a Reply

Your email address will not be published. Required fields are marked *