[Python-ideas] Better error messages for missing optional stdlib packages

Marcus Harnisch mh-python at online.de
Wed Oct 3 16:29:45 EDT 2018

Hi all

When trying to import lzma on one of my machines, I was suprised to get 
a normal import error like for any other module. According to the docs 
lzma has been part of stdlib since 3.3. Further digging revealed that 
the error is due to the fact that xz wasn't compiled in when building 
Python. Since I suspect that there are other optional stdlib modules, 
this made me think whether the message in those cases should look a 
little more polished. Perhaps installing a stub module that prints some 
informative text before raising the relevant exception or similar.
Also, maybe add a little note in the docs, stating that despite being 
part of stdlib this module might not be available on all systems.


More information about the Python-ideas mailing list