Get Available Modules

With PHP, you have phpinfo() , which lists the installed modules, and then from there look what they do.

Is there any way to see which packages / modules are installed for import?

+44
python
Oct 17 '10 at 8:13
source share
5 answers

Type help() in the interpreter

then

 To get a list of available modules, keywords, or topics, type "modules", "keywords", or "topics". Each module also comes with a one-line summary of what it does; to list the modules whose summaries contain a given word such as "spam", type "modules spam". help> modules 
+62
Oct 17 '10 at 8:40
source share

If you use ipython , this is an improved interactive Python shell (aka REPL "), you can enter import (note the space at the end), and then press the [TAB] key to get a list of the modules to be imported.

As indicated in this SO entry , you will have to reset the hash of the modules after installing (specific?) New ones. You probably don't need to worry about that.

If you are not using ipython and you have not tried it, it might be worth checking out. This is much better than the base Python shell or just about any other REPL I used.

ipython installation

If you are using linux, most likely an ipython package that you can install using system management tools. Others will want to follow these instructions .

If your installation route requires the use of easy_install , you can use pip instead. pip little smarter than easy_install , and does a better job of tracking file locations. This is very useful if you want to remove ipython .

Package listing

Please note that only modules are listed in the above tip. For a list that also includes packages containing modules, you can do from + [TAB] . An explanation of the difference between packages and modules can be found in the "Modules" section of the useful official Python tutorial .

#rtfm

As an added note, if you are very new to python, your time could be better spent looking at the standard documentation, than just choosing modules based on their name. The Python core documentation is well written and well organized. Organizational groups - Access to files and directories , Data types, etc. used in the documentation for library documentation are not always obvious from the names of modules / packages and are not actually used in other places, but serve as a valuable training tool.

+11
Oct 17 '10 at 8:37
source share

As aaronasterling says, all .py or .pyc files on sys.path are a module because it can be imported. There are scenarios that can allow you to find which plug-in is installed in site packages.

Yolk is a Python command line tool and library for obtaining information about packages installed by setuptools, easy_install and distutils, and can also request pypi packages.

+2
Oct 17
source share

You can list the available modules as follows:

 python -c "for dist in __import__('pkg_resources').working_set:print dist.project_name.replace('Python', '')" 
+2
Oct 17 2018-10-17
source share

It was very helpful. Here is the script version of this:

 # To list all installed packages just execfile THIS file # execfile('list_all_pkgs.py') for dist in __import__('pkg_resources').working_set: print dist.project_name.replace('Python', '') 
+2
Jul 26 '16 at 21:58
source share



All Articles