Consider
try:
import someProprietaryModule
except ImportError:
raise ImportError(\'It appears that is not installed...\')
This can be done like this in Python 2.7 and Python 3:
try:
import someProprietaryModule
except ImportError as e:
raised_error = e
if isinstance(raised_error, ImportError):
raise ImportError('It appears that <someProprietaryModule> is not installed...')
In Python 3.3 and later raise ... from None
may be used in this situation.
try:
import someProprietaryModule
except ImportError:
raise ImportError('It appears that <someProprietaryModule> is not installed...') from None
This has the desired results.