Home >Backend Development >Python Tutorial >How to check the installed modules in python

How to check the installed modules in python

尚
Original
2019-07-10 17:09:1217570browse

How to check the installed modules in python

As I use python for longer and longer, more and more python modules are installed. After a long time, I don’t know what modules are installed in my Python, so I If you want to check the python module you installed, the viewing method is summarized as follows:

1. Use the pydoc command under the CMD command line to view

In the command Run $pydoc modules under the line to view

2. Use help() in the python interactive interpreter to view

Enter in the interactive interpreter>> ;> help("modules"), the effect is the same as entering $pydoc modules on the command line

3. Import the sys module to view under the python interactive interpreter

# python的sys模块也是可以用来查看模块信息的
>>> import sys
>>> sys.modules.keys()

4. Use pip to view under the command line

# 如果你使用的是pip来作为你的python包管理器的话,可以在命令行下直接运行$ pip freeze</code>
#或者<code>$ pip list来查看安装包的信息,当然其它的包管理器也有类似的功能,
#同时,你也可以在python交互式解释器中导入pip模块来查看包信息
import pip
installed_packages = pip.get_installed_distributions()
installed_packages_list = sorted(["%s==%s" % (i.key, i.version)
for i in installed_packages])
print(installed_packages_list)

5. Use yolk to view

# 如果你安装过yolk的话可以使用yolk命令来查看包信息,你可以使用$pip install yolk来安装它 
yolk使用简单,只需在命令行下操作即可
$ yolk -l    #列出所有安装模块
$ yolk -a    #列出激活的模块
$ yolk -n    #列出非激活模块
$ yolk -U [packagename]  # 通过查询pypi来查看(该)模块是否有新版本

For more Python-related technical articles, please visit the Python Tutorial column to learn!

The above is the detailed content of How to check the installed modules in python. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn