Find python lxml version

前端 未结 6 1628
Happy的楠姐
Happy的楠姐 2021-02-03 18:32

How can I find the installed python-lxml version in a Linux system?

>>> import lxml
>>> lxml.__version__
Traceback (most recent call last):
  F         


        
6条回答
  •  长发绾君心
    2021-02-03 18:35

    You can use pip as well:

    import pip
    lxml_package = [pckg for pckg in pip.get_installed_distributions() 
                    if pckg.project_name == 'lxml'][0] # assuming lxml is installed
    print lxml_package.version
    

提交回复
热议问题