如何获得在计算机上安装的Python模块列表?


当前回答

如果我们需要列出Python shell中已安装的包,可以使用help命令,如下所示

>>> help('modules package')

其他回答

如果我们需要列出Python shell中已安装的包,可以使用help命令,如下所示

>>> help('modules package')

在windows上,在cmd中输入这个

c:\python\libs>python -m pip freeze

我通常使用pip list来获取包的列表(带有版本)。

当然,这也适用于虚拟环境。要显示只在虚拟环境中安装了什么(而不是全局包),请使用pip list——local。

下面的文档显示了所有可用的pip列表选项,并提供了几个很好的示例。

这会有所帮助

在终端或IPython中输入:

help('modules')

then

In [1]: import                      #import press-TAB
Display all 631 possibilities? (y or n)
ANSI                   audiodev               markupbase
AptUrl                 audioop                markupsafe
ArgImagePlugin         avahi                  marshal
BaseHTTPServer         axi                    math
Bastion                base64                 md5
BdfFontFile            bdb                    mhlib
BmpImagePlugin         binascii               mimetools
BufrStubImagePlugin    binhex                 mimetypes
CDDB                   bisect                 mimify
CDROM                  bonobo                 mmap
CGIHTTPServer          brlapi                 mmkeys
Canvas                 bsddb                  modulefinder
CommandNotFound        butterfly              multifile
ConfigParser           bz2                    multiprocessing
ContainerIO            cPickle                musicbrainz2
Cookie                 cProfile               mutagen
Crypto                 cStringIO              mutex
CurImagePlugin         cairo                  mx
DLFCN                  calendar               netrc
DcxImagePlugin         cdrom                  new
Dialog                 cgi                    nis
DiscID                 cgitb                  nntplib
DistUpgrade            checkbox               ntpath
help('modules')

在Python shell/提示符中。