TemplateSyntaxError: Caught ImportError while rendering: cannot import name utils

寵の児 提交于 2019-12-07 15:21:47

One of the causes for this in the past has been module import path issues.

Specifically, using a mod_wsgi installation compiled against one version of Python, and then using WSGIPythonPath or other means of setting the Python path to refer to a Python virtual environment constructed using a different Python version.

So, validate what version of Python mod_wsgi was compiled and installed for. If that is not Python 2.7, but an older Python version, you can get this specific problem.

For how to check what mod_wsgi was compiled for use:

http://code.google.com/p/modwsgi/wiki/CheckingYourInstallation#Python_Shared_Library

http://code.google.com/p/modwsgi/wiki/CheckingYourInstallation#Python_Installation_In_Use

It may also be worthwhile checking patch level revision differences of Python as well when looking at what mod_wsgi was compiled for. I do recollect that there was an issue a one point like this between Python 2.7.1 and 2.7.2 on there about.

That your Python site-packages is under /usr/local then quite possible that mod_wsgi using a different version under /usr.

In case someone stumbles over this while searching for this issue on Pyramid and sqlalchemy:

In conjunction with Pyramid, I had the same error ("ImportError: cannot import name util"). After hours of trial and error the only reason turned out that in production.ini I had set:

[server:main]
use = egg:waitress#main
host = 0.0.0.0
port = 80

I was also using Apache2 on port 80, seemed odd that this should be the same. After changing the port to e.g. 6543, the error disappeared and the WSGI server worked. None of the apache2-settings (WSGIPythonHome,WSGIPythonPath) where necessary.

Apparently unrelated and I don't know why the port-conflict caused this error, but it might help someone else with this issue.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!