ImportError: No module named trac

Apologies for the more gentile readers for this niche technical post, but I’m hoping to solve my technical brothers and sisters some frustrations with Trac, the excellent open source issue tracking system (we’ve been using it for more than 2 years to manage our work with Yankee Publishing, and it’s been truly transformational).

If you’re upgrading from Trac 0.11 to Trac 0.12 and you’re using Trac with Apache and mod_python you might find that after you upgrade you either get a “500 Internal Server Error” form Apache when you visit Trac or, if you have mod_python debugging on (or if you look in your Apache error log), an error message ImportError: No module named trac.

And yet you think that Trac actually is there: you can use trac-admin from the command line, and if you look where you think Trac should be (say, perhaps, in /usr/lib/python2.4/site-packages), you find that it is indeed there.

What’s going on?

It seems that Trac 0.12, at least when I installed it, installs itself as a “zipped egg.” I realized this was true when, after I did:


I ended up with a file (not a directory) in /usr/lib/python2.4/site-packages. My earlier versions of Trac were directories, not files. This, and this helpful post that says, in part:

mod_python 3.x is still unable to import modules from .zipped .egg-files. Command-line python (even older version 2.4 which is included into RHEL5/CentOS5) imports modules from zipped eggs without any problem, but not mod_python for the same version because it overrides the standard importer in its own special way.

So, in other words, Trac is there, it’s just that mod_python can’t see it because it’s zipped. Once I knew this, the solution was easy:

easy_install --always-unzip

Installing this way ensures that the resulting egg isn’t zipped, and once I did this Trac 0.12 ran without issue.


Chuck's picture
Chuck on May 29, 2010 - 04:05

I predict this will post will generate some very high traffic numbers over time.

Dani's picture
Dani on July 8, 2010 - 14:28

Thanks !!! it really helped me.
I just unzipped the egg and it solved the problem !

w00ten's picture
w00ten on July 8, 2010 - 19:36

THANK YOU!!!!!! After 2 and a half hours of dicking around with python and YUM being retarded I had this happen and this is the ONLY website that is even remotely on an understandable level or is even in a readable layout. Took me 30 seconds after reading this. Apparently Trac dev’s screwed up hard if they forgot to make sure the egg is unzipped.

ra's picture
ra on July 9, 2010 - 08:25

Posted some links to this page on trac website, in tickets concerning this problem.
Oh, and it helped me too, thanks.

schweini's picture
schweini on July 21, 2010 - 05:58

I installed the mastertickets plugin, and foolishly ran the included ‘’, and was wondering why it decided to update my trac installation to 0.12 without me asking it to. That dreaded 500 Internal Server Error appeared, and this post here is the ONLY place i found the solutino for this. Thanks a bunch!


Brennan's picture
Brennan on August 15, 2010 - 01:51

Thank you so much for posting this. To reiterate what an earlier commenter has said, it seems like you’re the only person on the web who has solved this problem, and it was such a quick solution.

PablooDemon's picture
PablooDemon on August 17, 2010 - 13:57

Thank You!

You saved my life. I was fighting with Trac for the last 3 days. It is finally working.

Thank You!

Peter Rukavina's picture
Peter Rukavina on August 17, 2010 - 14:34

Traffic numbers are low, but, as you can see from comments that follow, the post has been of some surgical help to those in need. Which was my reason for writing.

Pascal's picture
Pascal on November 12, 2010 - 22:27

OH MY GOD! Thank you!
This error was driving me insane!

Jack Chiu's picture
Jack Chiu on November 19, 2010 - 04:52

Thank you very much~

Redux's picture
Redux on January 6, 2011 - 02:55

mate — Thanks very much!

Spike's picture
Spike on January 23, 2011 - 16:38

This was helpful, but it didn’t work until I removed the Trac-0.12.1.py2.4.egg from /usr/lib/python2.4/site-packages then ran the easy_install —always-unzip —upgrade Trac==0.12.1 again.

janton's picture
janton on November 18, 2011 - 14:36

Yep Many Many thx!

Don&#39t forget to restart apache! (was needed in my case)


service httpd restart


FragFrog's picture
FragFrog on April 27, 2012 - 20:44

Thank you! A thousand times, thank you! I cannot believe this actually worked, but it did =D

Note: I had already installed the .egg’s the normal way, deleting them and then reinstalling them (with easy_install) did the trick.

Gunther Schadow's picture
Gunther Schadow on November 2, 2012 - 01:53


Jorge's picture
Jorge on December 2, 2013 - 17:37

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.

JP's picture
JP on April 19, 2016 - 17:58

This just saved me an evening... many thanks!

Add new comment