0

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.

1
  • Okay, you have a abc\greet.py file and you say there's greet folder... which is it? Commented Jun 22, 2014 at 22:02

1 Answer 1

2

Python already has a module named abc. Choose a different name.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.