How to find a python library’s version?

by , under python

Often times we need to check the version of a python library installed. I see there is no standard attribute convention for it. Most often it is  __version__ or Version or version or ver or Ver etc.,  So I use the dir command on the module to find out the exact attribute name for the version.

For example after installing pymongo…

1. Launch python shell
2. import pymongo
3. dir(pymongo)

This would provide all the methods, functions and attributes of pymongo module
If you know of a better way let me know.

Leave a Reply