Skip to content

Instantly share code, notes, and snippets.

@SEJeff
Last active April 11, 2019 12:33
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SEJeff/f24f88651e5c7b0272e226e4d8c87ffd to your computer and use it in GitHub Desktop.
Save SEJeff/f24f88651e5c7b0272e226e4d8c87ffd to your computer and use it in GitHub Desktop.
Print every python import for debugging import issues
# Courtesy of https://github.com/wimglenn
import sys
try:
import builtins
except ImportError:
# py2
import __builtin__ as builtins
old_import = builtins.__import__
def my_import(name, *args, **kwargs):
if name not in sys.modules:
print('importing --> {}'.format(name))
return old_import(name, *args, **kwargs)
builtins.__import__ = my_import
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment