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.
More Related Contents:
- How to catch and print the full exception traceback without halting/exiting the program?
- When I catch an exception, how do I get the type, file, and line number?
- Python type hinting with exceptions
- Python: Getting a traceback from a multiprocessing.Process
- Print an error message without printing a traceback and close the program when a condition is not met
- Catch and print full Python exception traceback without halting/exiting the program
- Print elements of list horizontally [closed]
- How do i get my code to return the the answer without the extra '' and ()
- Python eval() not multiplying properly
- Get raw key value
- Download file from web in Python 3
- Fixed digits after decimal with f-strings
- Print multiple arguments in Python
- Python, TypeError: unhashable type: ‘list’
- zip variable empty after first use
- ImportError: No module named ‘django.core.urlresolvers’
- Recursively iterate through all subdirectories using pathlib
- How do I determine what type of exception occurred?
- How to make a custom object iterable?
- Identifier normalization: Why is the micro sign converted into the Greek letter mu?
- How to create virtual env with python3
- selenium – Failed to execute ‘evaluate’ on ‘Document’: The string is not a valid XPath expression
- Windows can’t find the file on subprocess.call()
- How do I return dictionary keys as a list in Python?
- Rounding error in Python with non-odd number? [duplicate]
- What are the differences between bool() and operator.truth()?
- Python sort list by first number in a string
- Why does setattr fail on a bound method
- How to limit number of CPU’s used by a python script w/o terminal or multiprocessing library?
- Printing subscript in python