Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Snippet to print missing module error instead of Traceback with ModuleNotFoundError
moduleMissingError = 'Missing dependency module: Run "pip install -r requirements.txt" → Retry'
try:
import #<module1>
import #<package2>
import #<subpackage1>
except ImportError:
sys.exit(moduleMissingError)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment