Python: List of modules (>>> help ('modules') does not work)

I need a list of my modules, and they told me:

>>> help('modules')

Would do the trick. But I just get

Wait a little while I collect a list of all available modules ...

For over 10 minutes before I killed him.

Does anyone know what could be causing this? Or how could I see my modules? (System Ubuntu 9.10 / Python 2.6.4)

Thank,

Dan

+3
source share
3 answers

Install ipython

$ sudo apt-get install ipython

Then start ipython and type import <tab>where <tab> is the tab key

If you installed the python-pygraphviz package, you can use

import pygraphviz
+1
source

help("modules") , , . , - if __name__ == "__main__":, .

help("modules") pkgutil.walk_packages, " ". iter_modules, , .

>>> import pkgutil
>>> print [tup[1] for tup in pkgutil.iter_modules()]
['colorama', 'xlrd', 'BeautifulSoup', 'BeautifulSoupTests', '_ctypes', ...
#snip... 
..., 'pywin', 'win32ui', 'win32uiole']

, , sys.

>>> import sys
>>> sys.builtin_module_names
('__builtin__', '__main__', '_ast', '_bisect', '_codecs', ...
#snip...
..., 'thread', 'time', 'xxsubtype', 'zipimport', 'zlib')
+3

, import ed ( ),

>>> import sys
>>> print sys.modules

help('modules')- these are all available modules, that is, those that you ** can * import if you want. For me, this is not as long as for you, but if you have enough extensions installed, it can have thousands or tens of thousands of β€œpotential” modules to show, so it is not surprising that it may take a little time to collect this information.

+1
source

Source: https://habr.com/ru/post/1739257/


All Articles