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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T01:23:03+00:00 2026-05-22T01:23:03+00:00

I have a small web.py Python application that I would like to serve under

  • 0

I have a small web.py Python application that I would like to serve under Apache using mod_python. The web.py framework, as well as other third-party Python modules the application in question relies upon, are installed in a virtual environment. The virtual environment is created inside: /home/ayaz/Sandbox/Scrapper/

The relevant snippet from the virtual host configuration for Apache that I am using in order to set up this application is this:

<Location "/api">
    PythonPath "['/home/ayaz/Sandbox/Scrapper/lib/python2.5/site-packages/', '/home/ayaz/project/'] + sys.path"
    #PythonHandler wsgiref.modpython_gateway::handler
    PythonHandler modpython_gateway::handler
    SetHandler python-program 
    PythonOption wsgi.application device_api::main
    PythonOption device_api /api/
</Location>

On the browser when I try to access the /api URL however, I get a 500 from the server with the error in the logs saying that the web module imported from within the device_api.py file (which is my application) could not be found; in other words, I see an ImportError. I am not sure why it is unable to find the web module.

I know that the PythonPath directive is working, at least partially, judging from the fact that the Python interpreter is able to find the device_api.py file from the path defined in that directive. But, it is unable to find the rest of the modules for which the path is also defined in the same directive.

Any help with this will be deeply appreciated.

Thanks!

UPDATE #1

Ned’s reply had me looking
through the site-packages directory
for the virtual environment I have.
While the permissions looked fine
inside the directory to me, I realized
that mod_python/Apache was not able
to read the eggs. Since I installed
all the packages inside the virtual
environment using easy_install, they are all in the forms
of eggs. So, for example, if I moved
the directory
/home/ayaz/Sandbox/Scrapper/lib/python2.5/site-packages/web.py-0.34-py2.5.egg/web/
into
/home/ayaz/Sandbox/Scrapper/lib/python2.5/site-packages/
(essentially taking it out of the egg
file/directory), mod_python stopped
complaining about the missing web
module (of course, it then started
complaining about the missing rest of
the third-party modules).

I have Apache configured to run as my
user and group, that is ayaz, and I
checked that the permissions on the
/home/ayaz/.python-eggs directory
were fine.

I then used this Using eggs with
mod_python
tricked explained on
the Django deployment documentation
page. But it didn’t help.
Eventually, I bit the bullet, and for
each third-party module that
mod_python complained it couldn’t
find, I moved the actual directory
from inside the egg for that module
outside of the egg and into the
site-packages directory for the
virtual environment. This made
mod_python find the modules.

Now, I am really not sure why this
is happening, and why mod_python isn’t
able to read through the eggs.

  • 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-22T01:23:04+00:00Added an answer on May 22, 2026 at 1:23 am

    So as to answer this question, I am going to copy the update paragraphs from my question and post them as the answer (as they seem to explain to some extent how I manage to get rid of the problem).

    Ned’s reply had me looking through the
    site-packages directory for the
    virtual environment I have. While the
    permissions looked fine inside the
    directory to me, I realized that
    mod_python/Apache was not able to read
    the eggs. Since I installed all the
    packages inside the virtual
    environment using easy_install, they
    are all in the forms of eggs. So, for
    example, if I moved the directory
    /home/ayaz/Sandbox/Scrapper/lib/python2.5/site-packages/web.py-0.34-py2.5.egg/web/
    into
    /home/ayaz/Sandbox/Scrapper/lib/python2.5/site-packages/
    (essentially taking it out of the egg
    file/directory), mod_python stopped
    complaining about the missing web
    module (of course, it then started
    complaining about the missing rest of
    the third-party modules).

    I have Apache configured to run as my
    user and group, that is ayaz, and I
    checked that the permissions on the
    /home/ayaz/.python-eggs directory were
    fine.

    I then used this Using eggs with
    mod_python
    tricked explained on the
    Django deployment documentation page.
    But it didn’t help. Eventually, I bit
    the bullet, and for each third-party
    module that mod_python complained it
    couldn’t find, I moved the actual
    directory from inside the egg for that
    module outside of the egg and into the
    site-packages directory for the
    virtual environment. This made
    mod_python find the modules.

    Now, I am really not sure why this is
    happening, and why mod_python isn’t
    able to read through the eggs.

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

Sidebar

Related Questions

I have a small project I am doing in Python using web.py. It's a
Working on a small web spider in python, using the lxml module I have
I have a small web application based on asp.net 2010 that manages invoices. After
I have a small web application developed using Icefaces 1.8.2 and jsf 1.1 which
I'm making a small web application in Seaside. I have a login component, and
I am developing a small intranet based web application. I have YSlow installed and
I have a small JS function that does Ajax for me and another like
I have a web application written using CherryPy, which is run locally on 127.0.0.1:4321
I have a web based email application that logs me out after 10 minutes
I'm building a small web app with Python on GAE. I have an HTML

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.