Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot find python xlrd version

I have been using xlrd within python. However, xlrddoes not seem to provide a standard way to find its version number! I have tried:

  • xlrd.version()
  • xlrd.__version__
  • xlrd.version
  • xlrd.VERSION
  • xlrd.VERSION()
like image 225
Paul Avery Avatar asked May 31 '13 14:05

Paul Avery


1 Answers

You've almost got it: xlrd.__VERSION__.

Usually it's useful to see available attributes and methods by calling dir: dir(xlrd).


You can even iterate through the results of dir() see if version is inside:

>>> import xlrd
>>> getattr(xlrd, next(item for item in dir(xlrd) if 'version' in item.lower()))
'0.9.3'

A more reliable way, that would work for any installed package, is to use pkg_resources:

>>> import pkg_resources
>>> pkg_resources.get_distribution("xlrd").version
'0.9.3'
like image 199
alecxe Avatar answered Nov 17 '22 17:11

alecxe