我刚安装的Python模块:construct并statlib用setuptools这样的:
# 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模块都有一个属性,它保存模块的版本信息(通常类似于module.VERSION或者module.__version__),但有些则没有.
这些模块的特定示例是libxslt和libxml2.
我需要检查在运行时是否正在使用这些模块的正确版本.有没有办法做到这一点?
一个潜在的解决方案是在运行时读取源代码,哈希它,然后将它与已知版本的哈希值进行比较,但那是令人讨厌的.
有更好的解决方案吗?