python查看安装扩展版本
Python 2023/9/19 20:33:50 点击:不统计
转载%77%77%77请%2E%66%6F%72%61%73%70%2E%63%6E注明
本地环境python 都安装了哪些扩展,怎么查看版本,直接上代码
import pkg_resources
installed = {pkg.key for pkg in pkg_resources.working_set}
for name in installed:
v = pkg_resources.get_distribution(name).version
print(name ,":", v)
#如果判断是否安装了 某个扩展mysql并输出扩展名
if "mysql" in installed:
print("已经安装了,mysql ,它的版本是", pkg_resources.get_distribution('mysql').version )
查看安装扩展版本运行结果如下:
et-xmlfile : 1.1.0
elastic-enterprise-search : 7.15.0
zope.interface : 5.4.0
python-editor : 1.0.4
protego : 0.1.16
automat : 20.2.0
....
已经安装了,mysql ,它的版本是 0.0.3
以上就是python 查看是否安装扩展并查看对应扩展版本
原载于:本文原载于www.forasp.cn
·上一篇:python自动判断是否安装扩展 >> ·下一篇:python图片打马赛克 >>