相关疑难解决方法(0)

如何检查python模块的版本?

我刚安装的Python模块:constructstatlibsetuptools这样的:

# Install setuptools to be able to download the following
sudo apt-get install python-setuptools

# Install statlib for lightweight statistical tools
sudo easy_install statlib

# Install construct for packing/unpacking binary data
sudo easy_install construct
Run Code Online (Sandbox Code Playgroud)

我希望能够(以编程方式)检查他们的版本.是否python --version可以从命令行运行?

我的python版本是2.7.3.

python

585
推荐指数
20
解决办法
80万
查看次数

在运行时检查Python模块版本

许多第三方Python模块都有一个属性,它保存模块的版本信息(通常类似于module.VERSION或者module.__version__),但有些则没有.

这些模块的特定示例是libxslt和libxml2.

我需要检查在运行时是否正在使用这些模块的正确版本.有没有办法做到这一点?

一个潜在的解决方案是在运行时读取源代码,哈希它,然后将它与已知版本的哈希值进行比较,但那是令人讨厌的.

有更好的解决方案吗?

python module version

109
推荐指数
4
解决办法
7万
查看次数

标签 统计

python ×2

module ×1

version ×1