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

  • SEARCH
  • Home
  • 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 8268493
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T05:54:29+00:00 2026-06-08T05:54:29+00:00

When organising python project, this structure seems to be a standard way of doing

  • 0

When organising python project, this structure seems to be a standard way of doing it:

myproject\
    bin\
        myscript
    mypackage\
        __init__.py
        core.py
    tests\
        __init__.py
        mypackage_tests.py
setup.py

My question is, how do I import my core.py so I can use it in myscript?

both __init__.py files are empty.

Content of myscript:

#!/usr/bin/env python
from mypackage import core
if __name__ == '__main__':
    core.main()

Content of core.py

def main():
    print 'hello'

When I run myscript from inside myproject directory, I get the following error:

Traceback (most recent call last):
  File "bin/myscript", line 2, in <module>
    from mypackage import core
ImportError: No module named mypackage

What am I missing?

  • 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-06-08T05:54:32+00:00Added an answer on June 8, 2026 at 5:54 am

    Usually, setup.py should install the package in a place where the Python interpreter can find it, so after installation import mypackage will work. To facilitate running the scripts in bin right from the development tree, I’d usually simply add a simlink to ../mypackage/ to the bin directory. Of course, this requires a filesystem supporting symlinks…

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

Sidebar

Related Questions

After asking organising my Python project and then calling from a parent file in
This is a question about organising lots of images in a web project. Say
What is the best way to organize code that belongs to the same project
I am really fond of python's capability to do things like this: if __name__
I am looking for hexagonal self-organizing map on Python. ready module. If one exists.
I've got 2 questions about organising Unit tests. Do I have to put test
Do you know any blueprints for organizing a WCF application in a way similar
After starting out with Python on Ubuntu Linux, I've now for a good while
i am looking for something similar to Organizing GUI code , but for Python
I have an idea of organising a game loop. I have some doubts about

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.