How can I get a list of locally installed Python m

2018-12-31 12:37发布

I would like to get a list of Python modules, which are in my Python installation (UNIX server).

How can you get a list of Python modules installed in your computer?

22条回答
余生请多指教
2楼-- · 2018-12-31 13:07

I ran into a custom installed python 2.7 on OS X. It required X11 to list modules installed (both using help and pydoc).

To be able to list all modules without installing X11 I ran pydoc as http-server, i.e.:

pydoc -p 12345

Then it's possible to direct Safari to http://localhost:12345/ to see all modules.

查看更多
泛滥B
3楼-- · 2018-12-31 13:07

Very simple searching using pkgutil.iter_modules

from pkgutil import iter_modules
a=iter_modules()
while True:
    try: x=a.next()
    except: break
    if 'searchstr' in x[1]: print x[1]
查看更多
梦寄多情
4楼-- · 2018-12-31 13:10
  • In ipython you can type "importTab".

  • In the standard Python interpreter, you can type "help('modules')".

  • At the command-line, you can use pydoc modules.

  • In a script, call pkgutil.iter_modules().

查看更多
笑指拈花
5楼-- · 2018-12-31 13:11

Aside from using pip freeze I have been installing yolk in my virtual environments.

查看更多
登录 后发表回答