How to list all installed packages and their versions in Python?
If you have pip install and you want to see what packages have been installed with your installer tools you can simply call this:
pip freeze
It will also include version numbers for the installed packages.
Update
pip has been updated to also produce the same output as pip freeze
by calling:
pip list
Note
The output from pip list
is formatted differently, so if you have some shell script that parses the output (maybe to grab the version number) of freeze
and want to change your script to call list
, you'll need to change your parsing code.
help('modules')
should do it for you.
in IPython :
In [1]: import #import press-TABDisplay all 631 possibilities? (y or n)ANSI audiodev markupbaseAptUrl audioop markupsafeArgImagePlugin avahi marshalBaseHTTPServer axi mathBastion base64 md5BdfFontFile bdb mhlibBmpImagePlugin binascii mimetoolsBufrStubImagePlugin binhex mimetypesCDDB bisect mimifyCDROM bonobo mmapCGIHTTPServer brlapi mmkeysCanvas bsddb modulefinderCommandNotFound butterfly multifileConfigParser bz2 multiprocessingContainerIO cPickle musicbrainz2Cookie cProfile mutagenCrypto cStringIO mutexCurImagePlugin cairo mxDLFCN calendar netrcDcxImagePlugin cdrom newDialog cgi nisDiscID cgitb nntplibDistUpgrade checkbox ntpath
If you want to get information about your installed python distributions and don't want to use your cmd console or terminal for it, but rather through python code, you can use the following code (tested with python 3.4):
import pip #needed to use the pip functionsfor i in pip.get_installed_distributions(local_only=True): print(i)
The pip.get_installed_distributions(local_only=True)
function-call returns an iterable and because of the for-loop and the print function the elements contained in the iterable are printed out separated by new line characters (\n
).The result will (depending on your installed distributions) look something like this:
cycler 0.9.0decorator 4.0.4ipykernel 4.1.0ipython 4.0.0ipython-genutils 0.1.0ipywidgets 4.0.3Jinja2 2.8jsonschema 2.5.1jupyter 1.0.0jupyter-client 4.1.1#... and so on...