Catch python ‘ImportError’ if import from source directory [duplicate]
ImportError: No module named foo actually means the module foo.py or package foo/__init__.py could not be found in any of the directories in the search path (sys.path list). Since sys.path usually contains . (the current directory), that’s probably what you meant by being in the source directory. You are in the top-level directory of package …