Last active
April 11, 2019 12:33
-
-
Save SEJeff/f24f88651e5c7b0272e226e4d8c87ffd to your computer and use it in GitHub Desktop.
Print every python import for debugging import issues
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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