List of modules available for import inside Python?

clurker nospam at spamhaters.com
Sat Sep 6 16:18:55 EDT 2008


Michele Simionato wrote:

> On Aug 28, 6:21 am, ssecorp <circularf... at gmail.com> wrote:
>> Is there a way to view all the modules I have available for import
>> from within Python?
>> Like writing in the interpreter:
> 
> Try:
> 
>>>> help()
> help> modules
> Please wait a moment while I gather a list of all available modules...
> <snip>

This looks like it could be a useful tool, but when I try it
I get the following:

Please wait a moment while I gather a list of all available modules...

/usr/lib/python2.5/site-packages/reportlab/lib/PyFontify.py:35:
Warning: 'with' will become a reserved keyword in Python 2.6
/usr/lib/python2.5/site-packages/reportlab/lib/PyFontify.py:36:
Warning: 'with' will become a reserved keyword in Python 2.6
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.5/site.py", line 346, in __call__
    return pydoc.help(*args, **kwds)
  File "/usr/lib/python2.5/pydoc.py", line 1645, in __call__
    self.interact()
  File "/usr/lib/python2.5/pydoc.py", line 1663, in interact
    self.help(request)
  File "/usr/lib/python2.5/pydoc.py", line 1679, in help
    elif request == 'modules': self.listmodules()
  File "/usr/lib/python2.5/pydoc.py", line 1797, in listmodules
    ModuleScanner().run(callback)
  File "/usr/lib/python2.5/pydoc.py", line 1848, in run
    for importer, modname, ispkg in pkgutil.walk_packages():
  File "/usr/lib/python2.5/pkgutil.py", line 110, in walk_packages
    __import__(name)
  File "/usr/local/lib/python2.5/site-packages/PIL/__init__.py", line 1342,
in <module>

  File "/usr/local/lib/python2.5/site-packages/PIL/__init__.py", line 927,
in main

UnboundLocalError: local variable 'given_files' referenced before assignment
>>>  

which could be because I am fairly free and unrestrained when
it comes to installing stuff, and I see now I have modules
on both /usr/lib/python2.5 and /usr/local/lib/python2.5

Apparently python knows about them both, but I don't know I
haven't introduced an incompatibility somewhere...and that PIL
package showing up at the tail of the errors was one of my
more recent additions...

Any help will be appreciated,

sc




More information about the Python-list mailing list