Jython does not catch Exceptions
问题 Jython doesn't have the -m option, and it raises an error with from .utils import * . The solution is not to use relative path sys.path.insert(0, os.path.dirname(__file__)) from utils import * As I need to use the code both Jython and CPython, I came up with this command: try: from .utils import * except Exception: # Jython or Python with python context/context.py invocation sys.path.insert(0, os.path.dirname(__file__)) from utils import * However, Jython doesn't seem to catch the exception,