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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:16:20+00:00 2026-06-11T16:16:20+00:00

In Python 2.6.6, I have a module named the same as its grandparent. My

  • 0

In Python 2.6.6, I have a module named the same as its grandparent. My project structure (a web app using Flask) looks roughly like this:

panel/
  run.py
  panel/
    __init__.py
    database.py
    views/
      __init__.py
      root.py
      dash.py
      panel.py
    users/
      __init__.py
      models.py

Note that the package name, next to run.py, is panel. I also have a module named panel.views.panel. If from within panel/__init__.py I import panel.views.panel, using any of these three styles:

from panel.views import panel
from panel.views import panel as panel_view
import panel.views.panel as panel_view

After importing panel.py, none of my other imports work. For example, panel.users.models attempts to import database.py, and this traceback is thrown:

Traceback (most recent call last):
  File "run.py", line 5, in <module>
    from panel import app
  File "/opt/www/panel/panel/__init__.py", line 8, in <module>
    from panel.views import root
  File "/opt/www/panel/panel/views/root.py", line 9, in <module>
    from panel import database;
ImportError: cannot import name database

I spoke with a few people in the #pocoo IRC channel, and from what they described, the issue is that from within views/root.py, Python thinks import panel.database means to import database from panel.py sitting next to it.

This doesn’t make sense to me though because PEP 328 outlines (what reads like) this exact problem, and made absolute imports the default in order to fix this. I’m using Python 2.6.6, so this should be the default. Just to be sure though, I added the line from __future__ import absolute_import but this didn’t make a difference; the same error importing database.py occurred.

Renaming panel.py fixes this issue, however, I’m extremely curious to know why this doesn’t work as it is written, and especially if there’s anything I can do to make this work.

  • 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-11T16:16:21+00:00Added an answer on June 11, 2026 at 4:16 pm

    You said you added the line from __future__ import absolute_import, but you didn’t say to which file you added it. Be sure to add it to root.py.

    This section of the python tutorial explains what is happening in your case: http://docs.python.org/tutorial/modules.html#intra-package-references

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

Sidebar

Related Questions

I have a python module that I've been using over the years to process
In a Python system for which I develop, we usually have this module structure.
I have a python logger set up, using python's logging module. I want to
I have been trying to manupulate registry key from python using the win32api module
I have a python module that imports a module generated with swig. When I
I have a python file testHTTPAuth.py which uses module deliciousapi and is kept in
In Python 2.4 and later, configuring the logging module to have a more basic
I have written a Python module, and I have two versions: a pure Python
I have created a simple Python module and want to distribute it with pip.
I have a simple Python script that uses the socket module to send 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.