When Automatically Importing Modules From A Subfolder, Their Imports Fail
I've read through a couple of similar questions, notably this one about imp.load_module which seems to be close to what I want, but I can't understand why I'm still getting ImportE
Solution 1:
Maybe you can solve this by changing the import to:
from .utilsimport http
Or by adding the folder you import to the Python Path:
sys.path.append(os.path.join(root, source))
When you import modules in thirdparty
, the place Python looks for modules is still the main directory. The initial import works, because you give the right path to imp.find_module
, but after that Python has no idea where to look for the modules.
Post a Comment for "When Automatically Importing Modules From A Subfolder, Their Imports Fail"