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 6162013
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T21:34:50+00:00 2026-05-23T21:34:50+00:00

I develop python application which I decided to turn into package to be installed

  • 0

I develop python application which I decided to turn into package to be installed by easy_install or pip later. I’ve used search to find several good sources about directory structure for python packages See this answer or this post.

I created following structure (I’ve omitted several files in the list to make structure be more clear)

Project/
|-- bin/
|-- my_package/
|   |-- test/
|   |   |-- __init__.py
|   |   |-- test_server.py
|   |-- __init__.py
|   |-- server.py
|   |-- util.py
|-- doc/
|   |-- index.rst
|-- README.txt
|-- LICENSE.txt
|-- setup.py           

After that I created executable script server-run

#!/usr/bin/env python
from my_package import server
    
server.main()

which I placed into bin directory. If I install my package with python setup.py install or via pip/easy_install everything works fine, I can run server-run and my server starts to handle incoming requests.

But my question is how to test that server-run works in development environment (without prior installation of my_package)? Also I want to use this script to run latest server code for dev purposes.

Development happens in Project directory so I am getting ImportError if I run ./bin/server-run

user@host:~/dev/Project/$ ./bin/server-run
Traceback (most recent call last):
  File "./bin/server-run", line 2, in <module>
    import my_package
ImportError: No module named my_package

Is it possible to modify bin/server-run script so it will work if I run it from another folder somewhere in the filesystem (not necessarily from Project dir)? Also note that I want to use (if it is possible to achieve) the same script to run server in production environment.

  • 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-23T21:34:51+00:00Added an answer on May 23, 2026 at 9:34 pm

    You need relative imports. Try

    from .. import mypackage
    

    or

    from ..mypackage import server
    

    The documentation is here

    http://docs.python.org/tutorial/modules.html#intra-package-references

    These work on Python 2.5 or newer.

    To do it only in the development version, try:

    try:
        from my_package import server
    except ImportError:
        from ..my_package import server
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to develop my application using google app engine into which I will
I need to develop a small-medium sized desktop GUI application, preferably with Python as
I develop a critical application used by a multi-national company. Users in offices all
I'm planning to use Python to develop a web application. Anybody has any idea
I need to develop a file indexing application in python and wanted to know
I want to develop an application which uses Django as Fronted and Celery to
I just want to develop some Java and Python applications on Windows XP. Which
I develop cross-platform application for Maemo/Meego/Linux platforms using python (PySide). I use a workaround
I want to develop a photo gallery application using google app engine and python.
I'm going to develop a multimedia application which is running mostly on windows. I

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.