[Tutor] How to get module name from ImportError

Nikunj.Badjatya at emc.com Nikunj.Badjatya at emc.com
Mon Nov 21 06:54:02 CET 2011


Hi All,

Please look at the following snippet.
{{{

# User defined modules
try:
    from scripts import precheck
    from scripts import validate
    from scripts import constants
except ImportError:
    print("ERROR: One of the modules (..scripts/precheck.py, validate.py, constants) is not present.")
    print("INFO : Please verify the above modules, and restart the installation")
    sys.exit(1)

}}}

See the red line.
I want to get the name of the particular module which is not available and hence causing ImportError.
One of the ways can be to get the STDERR and process it using re. !?

Is there a better alternate available .?

Thanks
Nikunj
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20111121/081ee532/attachment.html>


More information about the Tutor mailing list