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


当前回答

从外壳开始

ls site-packages

如果没有帮助,你可以这样做。

import sys
import os
for p in sys.path:
    print os.listdir( p )

看看会产生什么。

其他回答

pip3 freeze

全局运行此命令-将显示所有全局安装 在虚拟环境上运行此命令-将显示所有本地安装

在ipython中,你可以输入“importTab”。 在标准的Python解释器中,您可以输入“help('modules')”。 在命令行中,您可以使用pydoc模块。 在脚本中,调用pkgutil.iter_modules()。

试试这些

pip list

or

pip freeze

这会有所帮助

在终端或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

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

>>> help('modules package')