Seeing the updated question, I think the problem is that you should do the import, including the root of your dependency tree: MMD.
Therefore, they should look like this:
from MMD.misc import utils
And also you need to call python
with the -m
option:
python -m MMD.actions.DummyAction
Edit: You said that MMD.py
contains the main thing, but cannot be your executable file, but because it is a module (located inside the directory with the __init__.py
file). MMD
is similar to your library, so you need the executable to be outside and use that library.
You can find [here] some guidelines for organizing your project.
If you can change the structure of the project, I suggest doing it as follows:
MMD/ βββ runner.py βββ mmd βββ __init__.py βββ main.py βββ /actions β βββ __init__.py β βββ DummyAction.py βββ /misc β βββ __init__.py β βββ utils.py βββ /triggers βββ DummyTrigger.py βββ __init__.py
Then, in any file inside the MMD
directory, each import should start with MMD
, for example:
from mmd.misc import utils from mmd.actions import DummyActions
And you put your main code, which is now inside MMD.py
inside the Main
class in main.py
, with something like:
# main.py from mmd.misc import utils class Main: def start_session(self): utils.function() # etc ...
And then in runner.py
you do something like:
So, inside the MMD
directory that calls python runner.py
, you have to execute your code, and you can also make the runner.py
, so just ./runner.py
will run your code.
And run your module with:
python -m MMD.actions.DummyAction
I would do it this way because this method is open to future implementation (and almost looks like linear guides).
If instead you cannot, try removing __init__.py
from the MMD
directory.