ImportError: No module named trac.web.modpython_frontend

One of the reasons why you might get the error:

ImportError: No module named trac.web.modpython_frontend

after installing Trac is because of the fact that apache may not be able to create the Python egg cache, which is detailed in the Trac wiki right here. This will also generate the above error if not set up correctly. Create a directory for the files, change the owner to www-data.www-data (or something else, depending on which user you run Trac under) and rejoice.

The settings needed in the vhost configuration (.. or wherever you have your configuration ..):

    
        SetHandler mod_python
        PythonInterpreter main_interpreter
        PythonHandler trac.web.modpython_frontend
        PythonOption TracEnvParentDir /path/to/trac
        PythonOption TracUriRoot /
        PythonOption PYTHON_EGG_CACHE /path/to/directory/you/created
    

You can easily do a quick test by setting the path to /tmp and checking if that solved your problem. If it did, create a dedicated directory and live happily ever after. If it didn’t, continue your quest. Check for genshi and other dependencies. Do a search on Google ™.

Hopefully everything works again.

BTW: Another reason for this error might be that your trac installation may no longer be available (if your installation uses a version number in the library path and you upgraded the python version, this path will change – and your old libraries may not have been copied over), so it might help reinstalling Trac in your new environment:

easy_install -U Trac

.. and then try again (thanks to Christer for reporting on this after he had the same problem).

2 thoughts on “ImportError: No module named trac.web.modpython_frontend”

  1. Also ensure that the Trac egg was unzipped during easy_install installation:

    For example:
    /usr/lib/python2.4/site-packages/Trac-0.12.1-py2.4.egg

    Should be a directory with stuff in it. If not, install the egg like easy_install –always-unzip Trac

  2. I had a similar problem and after i tried everything i found that the problem was in the permissions of the /usr/lib/python2.4/site-packages directory (i installed trac as root), i changed the owner of the directory and all subdirectories and files and it worked like a charm, maybe this could help anyone with this similar problem.

Leave a Reply

Your email address will not be published. Required fields are marked *