Image

Imagevorpal wrote in Imagepython_dev

Python 3 module import problem

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!