0

I am receiving this error when trying to use Python Server Pages with Mod_Python in Apache:

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
asked Oct 27, 2011 at 13:47
1
  • mod_python is deprecated, use mod_wsgi Commented Oct 27, 2011 at 14:08

2 Answers 2

1

Looks like your index.psp file either has a __future__ import that isn't at the top of the file, or (more likely imo) the file that is including your index.psp for processing is doing a bunch of work before the __future__ import is hit causing the error.

answered Oct 27, 2011 at 14:10
Sign up to request clarification or add additional context in comments.

1 Comment

I believe this to be the case - I just removed the from future imports
0
from __future__ import print_function

I don't think that you have to import the print_function to do statements like this

print("somthing")

Did you try it without this import?

answered Oct 27, 2011 at 14:06

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.