ImportError no module named ''

Hello All,

I have created a small scheduler as a few objects to work with it. I am trying to organize my project by placing this code into a python package. I have created my package and copied it to the lib folder on the device. I import it into my code as follows:

from SchedulerPackage import Scheduler
from SchedulerPackage import PinControlledTask
from SchedulerPackage import TimedTask

Before my code even has a chance to run the program crashes on the imports giving the error:
Traceback (most recent call last):
File “main”, line 5, in
File “/flash/lib/SchedulerPackage/init.py”, line 1, in
File “/flash/lib/SchedulerPackage/PinControlledTask.py”, line 4, in
TypeError: cannot create ‘module’ instances

My package has an init.py and following the read me on the github page I could be able to use my created classes.

I am willing to share my code, I really just need to figure out why I can not access/create the included objects.

I fixed the issue on my own. I was importing the classes incorrectly.

The correct import is

from SchedulerPackage.Scheduler import Scheduler
from SchedulerPackage.PinControlledTask import PinControlledTask
from SchedulerPackage.TimedTask import TimedTask

You need a file named init.py (two underscores on each side) in every folder in the hierarchy. This is what python looks for to know that it should access a particular folder. The files are meant to contain initialization instructions but even if you create them empty this will solve it. To get rid of this error “ImportError: No module named”, you just need to create init.py in the appropriate directory and everything will work fine.

http://net-informations.com/ql/pya/modules.html