对于模块:
required_modules = ['nose', 'coverage', 'webunit', 'MySQLdb', 'pgdb', 'memcache']
和节目:
required_programs = ['psql', 'mysql', 'gpsd', 'sox', 'memcached']
就像是:
# Report on the versions of programs installed
for module in required_modules:
try:
print module.__version__
except:
exit
很遗憾,module.__version__
并不存在于所有模块中。
解决方法是使用包管理器。当您使用安装库时简易安装 or pip,它保存已安装版本的记录。然后你可以这样做:
import pkg_resources
version = pkg_resources.get_distribution("nose").version
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)