how to list all installed modules

Scott David Daniels Scott.Daniels at Acm.Org
Wed Feb 18 13:10:53 EST 2009


harryos wrote:
> Is there a way to list all the installed modules in my python
> installation.I recently installed pygame and when i tried to import it
> like
>>> import pygame
> it complained that no such module was found.I can see the pygame
> directory in F:\Python25\Lib\site-packages in my machine,but am unable
> to import the module.So I was wondering if there is a way to list all
> the installed modules

Are you running F:\Python25\python.exe (or F:\Python25\pythonw.exe)?
open a command window (run cmd), and type:
     C:\> python
     ...
     >>> import sys
     >>> for dirname in  sys.path:
             print sys.path

I suspect something you see printed will surprise you.
Either the banner, identifying a Python version you were
not expecting, or perhaps a bunch of C:-based directories.
If this does not help you decipher the problem, try running
      python -v
Python verbose mode (You will get a _lot_ of output).
Then, when you (finally) get a ">>>" prompt, type:
    >>> import pygame
and you will see eaxctly what lookups are tried.

--Scott David Daniels
Scott.Daniels at Acm.Org



More information about the Python-list mailing list