python import error

Benjamin Kaplan benjamin.kaplan at case.edu
Wed Dec 11 02:23:49 EST 2013


On Tue, Dec 10, 2013 at 9:45 PM,  <smilesonisamal at gmail.com> wrote:
> On Wednesday, December 11, 2013 10:23:34 AM UTC+5:30, John Gordon wrote:
>> In <93405ea9-6faf-4a09-9fd9-ed264e3136e1 at googlegroups.com> smilesonisamal at gmail.com writes:
>>
>>
>>
>> >   File "aaa.py", line 5, in <module>
>>
>> >     from ccc.ddd import sss
>>
>> > ImportError: No module named ccc.ddd
>>
>>
>>
>> > directory structure as follows:
>>
>>
>>
>> > ccc
>>
>> > |
>>
>> >  ddd
>>
>> >    |
>>
>> >     aaa.py
>>
>> >     sss.py
>>
>>
>>
>> A python file isn't importable unless the directory also contains a file
>>
>> named __init__.py .
>>
>>
>>
>> Try making __init__.py files in the ccc and ddd directories.  If you
>>
>> don't know what to put in them, just leave them blank.
>>
>>
>> It is having __init__.py as blank in ccc and ddd directories. But it still doesnot work.
>> --


What directory are you in when you execute the script? Python doesn't
look up for packages so if you're in ddd and calling "python aaa.py",
Python doesn't know about the ccc package. You'd just import sss, or
add the parent directory of ccc to sys.path.



More information about the Python-list mailing list