[Distutils] Getting an egg's version: better way?

Nathan R. Yergler nathan at yergler.net
Thu Mar 15 15:48:02 CET 2007

I have a situation where I want to get the version of an egg that's
installed.  I figured out the following, but wanted to know if I'm
missing something obvious that's easier::

  >>> import pkg_resources
  >>> p = pkg_resources.get_provider("cctagutils")
  >>> for line in p.get_metadata_lines("PKG-INFO"):
  ...    if line.find('Version: ') == 0:
  ...      version = line.split()[-1]



More information about the Distutils-SIG mailing list