Skip to content

Instantly share code, notes, and snippets.

@pkutaj
Created January 13, 2022 09:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pkutaj/f4d2a0821b80a38027f34fe679647b84 to your computer and use it in GitHub Desktop.
Save pkutaj/f4d2a0821b80a38027f34fe679647b84 to your computer and use it in GitHub Desktop.
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