Reputation: 315
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
Upvotes: 3
Views: 7632
Reputation: 176780
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.
Upvotes: 3