Python "module Not Found" Error When Importing From Folder?
I have the common problem of the 'module not found' error when trying to import a file within a folder in my project directory as a package. I've tried several solutions from Stack
Solution 1:
Change from .code import my_function
to from code import my_function
. The top level of a package is defined by the highest folder with an __init__.py
file. So the top level of your project is the reporting
folder and code.py
does not need to be a relative import. Best to either avoid relative imports or get an editor like PyCharm that will take care of it for you!
Post a Comment for "Python "module Not Found" Error When Importing From Folder?"