diff --git a/kwant/__init__.py b/kwant/__init__.py index 59bd4e0f1b9b631c4e46c27828caeafc187b219b..c45de3fd9fac82e270e530bb39c82630e08399a4 100644 --- a/kwant/__init__.py +++ b/kwant/__init__.py @@ -13,10 +13,15 @@ import numpy # Needed by C. Gohlke's Windows package. try: from . import _system except ImportError: - msg = """Error importing Kwant: You should not try to import Kwant from - its source directory. Please exit the Kwant source distribution directory, - and relaunch your Python intepreter from there.""" - raise ImportError(msg) + import inspect + if len(inspect.trace()) == 1: + msg = """Error importing Kwant: + You should not try to import Kwant from its source directory. + Please exit the Kwant source distribution directory, and relaunch + your Python intepreter from there.""" + raise ImportError(msg) + else: + raise from ._common import KwantDeprecationWarning __all__.append('KwantDeprecationWarning')