问题描述:

I had a Debian Squeeze system, with the following script:

#!/bin/sh

/srv/trac/hooks/trac-post-commit-hook -p "/srv/trac" -r "$2"

After upgrade to Wheezy, the script failed with

Traceback (most recent call last):

File "/srv/trac/hooks/trac-post-commit-hook", line 106, in <module>

from trac.env import open_environment

ImportError: No module named trac.env

I installed the modules (Trac and others) again with easy_install, but that didn't solve the problem. However, this hack worked:

#!/bin/sh

export PYTHONPATH="/usr/local/lib/python2.7/dist-packages/Trac-0.12-py2.7.egg"

/srv/trac/hooks/trac-post-commit-hook -p "/srv/trac" -r "$2"

WSGI has the same problem, and I was not able to fix it yet.

What's wrong here? How can I avoid this evil hack?

网友答案:

It sounds like a problem with python search path when upgrading from Squeeze to Wheezy. You can try to debug sys.path to find if there is any problem. You should also check easy-install.pth to modify the site installed package.

I highly recommend to use virtualenv to manage python packages, so you won't have python path problem or package conflict when you move across machines or operation systems.

相关阅读:
Top