Python/HTML集成E

2024-04-26 09:20:08 发布

您现在位置:Python中文网/ 问答频道 /正文

我在Apache中尝试将Python服务器页与Mod\u Python一起使用时收到以下错误:

File "/usr/lib/python2.7/dist-packages/mod_python/importer.py", line 1537, in HandlerDispatch
default=default_handler, arg=req, silent=hlist.silent)

File "/usr/lib/python2.7/dist-packages/mod_python/importer.py", line 1229, in _process_target
result = _execute_target(config, req, object, arg)

File "/usr/lib/python2.7/dist-packages/mod_python/importer.py", line 1128, in _execute_target
result = object(arg)

File "/usr/lib/python2.7/dist-packages/mod_python/psp.py", line 336, in handler
p = PSP(req)

File "/usr/lib/python2.7/dist-packages/mod_python/psp.py", line 119, in __init__
self.load_from_file()

File "/usr/lib/python2.7/dist-packages/mod_python/psp.py", line 191, in load_from_file
code = compile(source, filename, "exec")

  File "/var/www/inventory/index.psp", line 3

    <% from __future__ import print_function

SyntaxError: from __future__ imports must occur at the beginning of the file

Tags: infrompymodtargetlibpackagesusr
2条回答

看起来像你的索引.psp文件的__future__导入不在文件顶部,或者(更可能是imo)包含索引.pspfor processing在命中__future__导入之前执行了大量工作,从而导致错误。在

from __future__ import print_function

我认为您不必导入print_function来做这样的语句

^{pr2}$

你试过没有这个进口的吗?在

相关问题 更多 >