Home/Support/Support Forum/digi xbee python version
Welcome to Digi Forum, where you can ask questions and receive answers from other members of the community.

digi xbee python version

0 votes

I need to manage several version of the digi python library https://github.com/digidotcom/xbee-python/releases

And normally in python to get the version of the package, I just do
import package_name
However it doesn't work with the digi-xbee one. I have check and at least in the old release I a unable to find the __version__ file.
So how can I check the version of the digi xbee library that I am currently using from python.

Thanks in advance
asked Sep 28, 2020 in 3rd Party Python and API development in other Languages by vincentlc New to the Community (2 points)

Please log in or register to answer this question.

1 Answer

+2 votes
Best answer
Hi vincentlc,

The __version__ attribute is a de-facto standard that modules and packages SHOULD provide, but it is not mandatory (see https://www.python.org/dev/peps/pep-0396/). It seems the digi-xbee library does not provide this attribute.

I did some experimentation and found that you can retrieve the version of the library using pkg_resources as follows:

>>> import pkg_resources
>>> pkg_resources.get_distribution('digi-xbee').version

I will suggest that the Python XBee library developers add a __version__ attribute to future releases.
answered Sep 30, 2020 by tckr Veteran of the Digi Community (514 points)
selected Sep 30, 2020 by vincentlc
Thanks a lot, works perfectly