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


当前回答

我在OS x上遇到了一个自定义安装的python 2.7。它需要X11来列出已安装的模块(使用help和pydoc)。

为了能够在不安装X11的情况下列出所有模块,我运行pydoc作为http-server,即:

pydoc -p 12345

然后,可以将Safari定向到http://localhost:12345/以查看所有模块。

其他回答

作品不考虑Pip版本

在python编辑器或IPython中运行以下命令:

import pkg_resources
installed_packages = {d.project_name: d.version for d in pkg_resources.working_set}
print(installed_packages)

阅读其他答案并将这个组合组合在一起,这是Python中最快和最简单的方法。

找到特定的包

你可以很方便地从词典中获取条目。

安装packages[‘pandas’]>> 1.16.4'

善用Pip List

pip列表将在你的jupyter笔记本中运行,简化了“快速检查” 与其他实用程序(如grep)结合使用(如果已安装) 例如,PIP列表| grep pandas将为您提供当前的pandas版本

如果安装了anaconda python发行版,也可以使用

$conda list

除了上述解决方案。

help('modules')

在Python shell/提示符中。

这会有所帮助

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

在windows上,在cmd中输入这个

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