A A
RSS

Workaround for “ImportError: cannot import name compat” issue in Trac 0.11.x

Sun, Aug 10, 2008

Software, Workarounds

I had used Trac 0.10.4 for awhile before upgrading to 0.11. First time around I had no problems, but on a new server, a fresh install of 0.11.1 was giving me this error when I visit certain pages:

[Sun Aug 10 19:41:57 2008] [error] [client 69.204.200.139] PythonHandler trac.web.modpython_frontend: Traceback (most recent call last):, referer: http://issues.biodegradablegeek.com/congen9
[Sun Aug 10 19:41:57 2008] [error] [client 69.204.200.139] PythonHandler trac.web.modpython_frontend:   File "/usr/lib/python2.4/site-packages/mod_python/apache.py", line 299, in HandlerDispatch\n    result = object(req), referer: http://issues.biodegradablegeek.com/congen9
[Sun Aug 10 19:41:57 2008] [error] [client 69.204.200.139] PythonHandler trac.web.modpython_frontend:   File "/usr/lib/python2.4/site-packages/Trac-0.11.1-py2.4.egg/trac/web/modpython_frontend.py", line 148, in handler\n    from trac.web.main import dispatch_request, referer: http://issues.biodegradablegeek.com/congen9
[Sun Aug 10 19:41:57 2008] [error] [client 69.204.200.139] PythonHandler trac.web.modpython_frontend:   File "/usr/lib/python2.4/site-packages/Trac-0.11.1-py2.4.egg/trac/web/main.py", line 47, in ?\n    from trac.web.chrome import Chrome, referer: http://issues.biodegradablegeek.com/congen9
[Sun Aug 10 19:41:57 2008] [error] [client 69.204.200.139] PythonHandler trac.web.modpython_frontend:   File "/usr/lib/python2.4/site-packages/Trac-0.11.1-py2.4.egg/trac/web/chrome.py", line 40, in ?\n    from trac.util import compat, get_reporter_id, presentation, get_pkginfo, \\, referer: http://issues.biodegradablegeek.com/congen9

After further investigation, it appears I had two compat.py files on my system:

mercury@tryptamine: /usr/lib/python2.4/site-packages/Trac-0.11.1-py2.4.egg/trac $ find . -name compat*
./util/compat.py
./util/compat.pyc
./tests/functional/compat.py
./tests/functional/compat.pyc

Renaming compat.py to testcompat.py in trac/tests/functional/ fixes the problem perfectly:

cd /usr/lib/python2.4/site-packages/Trac-0.11.1-py2.4.egg/trac/tests/functional/
sudo mv compat.py testcompac.py
sudo mv compat.pyc testcompac.pyc

The compat.pyc file may also be deleted.

That’s it. No restarting Trac/httpd.

I don’t take credit for this. Thanks goes to Jashugan (trac-users)!

Tags: , , , , , , , , , , , , ,

3 Comments For This Post

  1. Dougal Matthews Says:

    Didn’t work for me… :(

  2. Isam Says:

    I’m surprised this problem still exists at all. I’ve been using Trac almost daily since I did the above, and have never had a problem. I’m still using 0.11.1.

    Have you tried installing the latest version in trunk?
    http://trac.edgewall.org/wiki/TracDownload#LatestDevelopmentSourceCode

    You might also have luck on the mailing list or #trac on irc.freenode.net

  3. danie Says:

    Great! It worked for me, using the last stable version (0.11.1).

Leave a Reply