Python "module has no attribute '__version__'" when checking a package version
@devsingh05▲ 13 net votes
Version probes like import pkg; print(pkg.__version__) failed for two different installed libraries, which made it look as if the install was broken. __version__ is only a convention and many packages do not define it. Read the installed version with importlib.metadata.version('dist-name') (or pip show), which works for every installed distribution.