Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7177709
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T16:46:14+00:00 2026-05-28T16:46:14+00:00

I’m trying to build a Python program with the structure shown at the end.

  • 0

I’m trying to build a Python program with the “structure” shown at the end.

The problem is that actions should be able to be executed as scripts as well (I’ve already included a main in them). When I try to execute DummyAction.py imports keep complaining they can’t find misc.

How can I use DummyAction.py as a script and still use the functions in utils.py?

DummyAction.py contains a class called DummyActionClass, and the same for DummyTrigger.py. In utils.py there are several functions that both actions and triggers use and MMD.py contains the main.

/MMD
├── __init__.py
├── MMD.py
├── /actions
│   ├── __init__.py
│   ├── DummyAction.py
├── /misc
│   ├── __init__.py
│   ├── utils.py
└── /triggers
    ├── DummyTrigger.py
    └── __init__.py

The import in DummyAction.py and DummyTrigger.py is:

from misc import utils

And the error is:

File "DDM/actions/DummyAction.py", line 11, in <module>
    from misc import utils
ImportError: No module named misc
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T16:46:15+00:00Added an answer on May 28, 2026 at 4:46 pm

    Seen the updated question, I think the problem is that you should do the import including the root of your dependecies tree: MMD.

    So they should all look like:

    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 but it can’t be your executable, and that’s because is a module (is inside a directory with an __init__.py file). MMD is like your library so you need the executable to be outside and use such library.

    You can find [here] some guidelines on how to organize your project.

    If you can change you project structure I’ll suggest to do it like this:

    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 every import should start with mmd, for example:

    from mmd.misc import utils
    from mmd.actions import DummyActions
    

    And you put your main code that now is inside MMD.py inside a 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:

    # runner.py
    from mmd.main import Main
    
    cli = Main()
    cli.start_session()
    

    This way inside the MMD directory calling python runner.py you would execute your code, and you can also make executable runner.py so a simply ./runner.py will run your code.
    And run your module with:

    python -m  mmd.actions.DummyAction
    

    I’d do it like this, becasue this way is open to future implementation (and is almost like in the line guides).

    If instead you can’t, then you can give it a try at removing __init__.py from the MMD directory.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to create an if statement in PHP that prevents a single post
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I am trying to render a haml file in a javascript response like so:
I am doing a simple coin flipping experiment for class that involves flipping a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.