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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:52:15+00:00 2026-05-23T14:52:15+00:00

This is a follow-up question to import python modules with the same name ,

  • 0

This is a follow-up question to import python modules with the same name, but as the two are somewhat unrelated, it’s probably better to ask a new question:

I have several python projects and they all have a conf package:

/some_folder/project_1/
  conf/
    __init__.py
    some_source_file.py

/another_folder/project_2/
  conf/
    __init__.py
    another_source_file.py

For each project, I have created a .pth file in the site-packages folder with this contents:

.../site-packages/project_1.pth:
import sys; sys.path.append('/some_folder/project_1/')

.../site-packages/project_2.pth:
import sys; sys.path.append('/another_folder/project_2/')

Now, accessing the conf module works for /some_folder/project_1/:

import conf.some_source_file

but not for /another_folder/project_2/:

import conf.another_source_file
AttributeError: 'module' object has no attribute 'another_source_file'

which is probably due to python only searching the first conf path underneath any folders in sys.path.

I have therefore turned project_1 and project_2 into python packages and added a symlink in either, so I can access both conf packages in a fully qualified fashion:

/some_folder/project_1/
  __init__.py
  project_1 <-- symlink to .
  conf/
    __init__.py
    some_source_file.py

/another_folder/project_2/
  __init__.py
  project_2 <-- symlink to .
  conf/
    __init__.py
    another_source_file.py

In an ordinary python script, I can now import modules from both conf packages:

import project_1.conf.some_source_file
import project_2.conf.another_source_file

However, when I try to do the same within an WSGI application using the mod_wsgi Apache module, the import fails for the second project. Specifically, the wsgi ‘start file’ (i.e. the one with a wsgi suffix referenced in the WSGIScriptAlias statement in the Apache config file for my virtual server) successfully imports a module in /another_folder/project_2/ which in turn imports project_2/conf/another_source_file.py.

The second import fails, despite the fact that /another_folder/project_2/ is in sys.path. The WSGI application is running in daemon mode.

How can I get this sorted ?

  • 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-23T14:52:16+00:00Added an answer on May 23, 2026 at 2:52 pm

    FWIW, this was dealt with on mod_wsgi mailing list and from memory turned out to be caused by presence of both a module and package with same name and was picking up wrong one.

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

Sidebar

Related Questions

This is a follow up question . So, Java store's integers in two's-complements and
This is a follow-up question to my previous post: Python/Scipy Interpolation (map_coordinates) Let's say
Update: Check out this follow-up question: Gem Update on Windows - is it broken?
This is a follow on question to How do I delete 1 file from
This is a follow-on question to the How do you use ssh in a
This is a follow up question to This Question . I like (and understand)
This is a follow-up question to this one . Take a look at these
This is a follow up question to a previous question I asked about calculating
This is a follow-on question from the one I asked here . Can constraints
This is a follow-up question to ASP.NET How to pass container value as javascript

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.