简体   繁体   English

dist升级到Wheezy之后,Python找不到easy_install安装的模块

[英]Python does not find Modules installed by easy_install after dist-upgrade to Wheezy

I had a Debian Squeeze system, with the following script: 我有一个Debian Squeeze系统,带有以下脚本:

#!/bin/sh
/srv/trac/hooks/trac-post-commit-hook -p "/srv/trac" -r "$2"

After upgrade to Wheezy, the script failed with 升级到Wheezy之后,脚本失败并显示

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. 我使用easy_install再次安装了模块(Trac和其他模块),但这并不能解决问题。 However, this hack worked: 但是,此hack有效:

#!/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. WSGI有同样的问题,我还不能解决。

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. 从Squeeze升级到Wheezy时,这听起来像是python搜索路径的问题。 You can try to debug sys.path to find if there is any problem. 您可以尝试调试sys.path来查找是否存在任何问题。 You should also check easy-install.pth to modify the site installed package. 您还应该检查easy-install.pth以修改站点安装的软件包。

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. 我强烈建议使用virtualenv来管理python软件包,因此在计算机或操作系统之间移动时,不会出现python路径问题或软件包冲突。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM