Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Module 'distro' has no '__version__' member #265

Closed
AdnanHodzic opened this issue Sep 10, 2020 · 2 comments
Closed

Module 'distro' has no '__version__' member #265

AdnanHodzic opened this issue Sep 10, 2020 · 2 comments

Comments

@AdnanHodzic
Copy link

As it's case with most Python packages, if you run i.e:

print("psutil version:", psutil.__version__)

you'll end up getting package version, i.e: psutil: 5.7.2

However, if I do the same for distro package, i.e:

print("distro:", distro.__version__)

I'll immediately get Module 'distro' has no '__version__' member

Would it be possible to add this functionality in one of the future versions instead of having to resort to hacks/workarounds in order to print distro package version as part of a Python app.

Thanks!

@jdufresne
Copy link
Member

The modern way to do this is with importlib.metadata.

>>> from importlib.metadata import version
>>> version('distro')
'1.5.0'

@jdufresne
Copy link
Member

Thanks for the report. Resolved in a3da4d4.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants