futurecoder icon indicating copy to clipboard operation
futurecoder copied to clipboard

Detect import errors for auto-installing

Open alexmojaki opened this issue 4 years ago • 0 comments

Some packages have optional dependencies that are only required for some functions. So importing the main package automatically installs it, but using it can still lead to an error. We can detect when this has happened to help users. It requires catching exceptions in execute, checking the caught exception as well as the chain of __cause__ and __context__ for ModuleNotFoundError, and looking at the name attribute. Then we tell the user to import the missing module explicitly to 'install' it.

alexmojaki avatar Sep 22 '21 21:09 alexmojaki