Here's the directory structure
.../Desktop/scratch/abc/greet.py
I have my import code module.py in abc
.../Desktop/scratch/module.py:
import sys
sys.path.append("C:\\Users\\Name\\Desktop\\scratch")
import abc.greet
I have created empty init file in abc and greet folders.
But when i run this code then error be like:
Traceback (most recent call last): File "<frozen importlib._bootstrap>", line 1519, in _find_and_load_unlocked AttributeError: 'module' object has no attribute '__path__'
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "module.py", line 4, in <module>
import abc.greet ImportError: No module named 'abc.greet'; abc is not a package
I don't understand why this happens? How is abc not a module when I have created the init file and also added the scratch directory to the search path.
PS: greet.py just contains a method hello which prints "hello world", if this info is of any use.
abc\greet.pyfile and you say there'sgreetfolder... which is it?