Top.Mail.Ru
Python
? ?
LiveJournal for python.
View:Personal Journal.
View:Friends.
View:Calendar.
Missed some entries? Then simply jump to the previous day or the next day.

Friday, October 8th, 2010

Subject:Python 3 module import problem
Time:1:07 pm.
Hi all!

Quick Python 3 question. I have a module I wrote in Python 2 and I'm trying to make it compatible with 3, but I'm having a bizarre error that I'm sure is extremely simple to fix. Here's the situation:

I have a directory for my module, say mymodule. Inside, I have an __init__.py file, and another file, say myfile.py. In __init__.py, I have the statement:

import myfile

However, when I'm in the directory containing mymodule, and I execute:

import mymodule

I get the following error:

ImportError: no module named myfile

This didn't happen in Python 2, and I'm not sure why it's happening in Python 3 or how to get __init__.py to properly search its own directory for modules when doing imports.

Can someone please help me or point me in the right direction?

Thanks so much, folks!
Comments: Read 2 orAdd Your Own.

LiveJournal for python.

View:User Info.
View:Friends.
View:Calendar.
View:Memories.
Missed some entries? Then simply jump to the previous day or the next day.

Image