3

I read through Add to python path mac os x and I figured doing that is a good idea, but still IDLE gives me a syntax error for a simple call of open(filename, mode), so I looked a little bit further and I found that I am able to do as stated in http://developer.apple.com/library/mac/#qa/qa1067/_index.html and set up an environment.plist in a .MacOSX folder, so I did that in my home dir and still no changes ... I am now lost :-)

Thats what I added as my python-path in .bash_profile and the same path in my environment.plist (without the :$PYTHONPATH):

PYTHONPATH="/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7:$PYTHONPATH"
export PYTHONPATH

EDIT: Thats where I get the syntax-Error... works fine in the interpreter

import xml.etree.ElementTree as et 
import json
app = Bottle()
@app.route('/proPass', method ='POST')
#here happens here, need it further down in the code... which is not really relevant 
f = open('/Users/mohi/Desktop/proPass_project/server_service/systems.xml', 'rw')
def getData():
 timestamp = request.POST.get('timestamp', '').strip()
 data = request.POST.get('data', '').strip()
 if timestamp:
 processData(data, timestamp)
run()

The error:

 File "proPass_script.py", line 9
 f = open('/Users/mohi/Desktop/proPass_project/server_service/systems.xml', 'rw')
 ^
 SyntaxError: invalid syntax
asked Aug 17, 2011 at 9:23
1
  • 1
    Put the exact and full traceback and error in between <pre> and </pre> so we can see exactly what might be the problem. Also, add a few lines of context -- often the error is on one of the lines before where it detects the error. Commented Aug 17, 2011 at 9:34

1 Answer 1

3

PYTHONPATH doesn't effect whether or not you get a SyntaxError -- only an ImportError. So, if you're getting a SyntaxError, you've got another problem with your code. Please post the code and we'll point it out.

Edit: Your error is on this line:

@app.route('/proPass', method ='POST')

The @ designates a decorator, which is only valid on the line immediately before a function definition (def), a class definition (class), or another decorator.

It shows the error on the first character of the open line because it's expecting a function or class definition there.

See the docs for function definitions for more info on decorators.

answered Aug 17, 2011 at 9:26
Sign up to request clarification or add additional context in comments.

3 Comments

k, didn't know that, was looking a bit around the net and I found people with similar problems and they had to set a pythonpath
This is more a comment than an answer.
omg ... Thank you, will keep that in mind ...I have to read the howto more precisely

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.