Skip to content

Instantly share code, notes, and snippets.

@SEJeff SEJeff/print_imports.py
Last active Apr 11, 2019

Embed
What would you like to do?
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
You can’t perform that action at this time.