Search This Blog

Sunday, March 16, 2014

ImportError handling

You run in to import errors by using the try...except blocks.
You run in to this error when the module that you are trying to import does not exist in the sys.path. However, if you want to gracefully continue your execution even if there is an import error (and if this what your program expects) then you can handle it using except.

try: import abcexcept ImportError: print("It is still OK to continue")


You can also chose to import sys path 

No comments:

Post a Comment