Workaround for “ImportError: cannot import name compat” issue in Trac 0.11.x
Sun, Aug 10, 2008
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 HandlerDispatchn 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 handlern 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)!
Why not subscribe to the feed?. If you’re on a mobile device I suggest Viigo
Tags: fix, workaround
October 16th, 2008 at 9:05 am
Didn’t work for me… :(
October 16th, 2008 at 10:35 am
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
October 30th, 2008 at 8:08 am
Great! It worked for me, using the last stable version (0.11.1).
August 5th, 2009 at 5:34 am
Thanks. worked. did have to reload apache though.
October 23rd, 2009 at 5:51 pm
Worked for mee, too, after an upgrade from 0.10.4 to 0.11.5 on a ubuntu system, thx a lot.
(had to restart)