2011-10-27 101 views
0

我收到試圖在Apache中使用Python服務器頁面與mod_python的,當這個錯誤:的Python/HTML積分誤差

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 
+0

mod_python已棄用,請使用mod_wsgi – gigimon

回答

1

看起來你index.psp文件要麼有一個__future__進口,是不是在文件的頂部,或者(更可能IMO)是包括你的處理index.psp文件做了一堆工作在導入__future__導致錯誤之前。

+0

我相信這是事實 - 我剛剛刪除了__future__這個import –

0
from __future__ import print_function 

我不認爲你必須導入print_function做報表像這樣

print("somthing") 

您是否嘗試過沒有此導入?