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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:47:25+00:00 2026-05-22T16:47:25+00:00

How to import modules from different folders? I have the following cgi-bin | py

  • 0

How to import modules from different folders? I have the following

cgi-bin
       | py
          |
           __init.py__
           http
             |
              __init.py__
              HttpFormParser.py
           xml
             |
              __init.py__
              XmlDocumentCreator.py

I want to import XmlDocumentCreator in HttpFormParser.py. How to do that ?

I’m doing

import py.xml.XmlDocumentCreator

in HttpFormParser.py and its throwing the following error.

/HttpFormParser.py", line 5, in <module> 
    import py.xml.XmlDocumentCreator
ImportError: No module named py.xml.XmlDocumentCreator
  • 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-22T16:47:26+00:00Added an answer on May 22, 2026 at 4:47 pm

    Just work out the directory you’re executing from, as told by sys.argv[0]. In this case, you want to get the cgi-bin directory since it contains py:

    import os
    import sys
    sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), 
        os.pardir, os.pardir)))
    import py.xml.XmlDocumentCreator
    

    P.S. if you’re using WSGI, you don’t need your Python code in a cgi-bin directory, where it could be downloaded if your .htaccess (or equivalent) is set wrong.

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

Sidebar

Related Questions

I have two modules like this (very very simplified): main.py: from window import *
For example: from datetime import <c-x><c-o>{list of modules inside datetime package}
I have dev and production systems. My production system is different from my dev
Assume the following code structure: #### 1/hhh/__init__.py: empty #### 1/hhh/foo/__init__.py: from hhh.foo.baz import *
I am trying to import a module from a different directory dynamically. I am
Something weird... I was working on importing files from different folders.. and was working
import sys sys.path.append('/home/myuser/svn-repos/myproject') from myproject.settings import * But, it says module not found when
A lot of modules I use import entire files into memory or trickle a
As I just found out import package does not make the package's modules available
I have created a php script to import rss feed into the database. The

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.