5

Help! i am getting this error again and again....on light table while i m trying to run python code

 File "C:\Python34\Lib\site.py", line 176
    file=sys.stderr)
        ^
SyntaxError: invalid syntax

This is a code with installation.

8
  • It looks as though you're trying to run Python 3 code under a Python 2 interpreter. Commented Jul 8, 2014 at 16:48
  • What's the value of your PYTHONPATH environment variable? Commented Jul 8, 2014 at 17:07
  • See also stackoverflow.com/q/20555517/270986 Commented Jul 8, 2014 at 17:16
  • I was frustrated so i passed every possible path to all folders. Here what i have set the path....C:\Python34\Lib;C:\Python34\DLLs;C:\Python34\include;C:\Python34\libs;C:‌​\Python34\Scripts;C:\Python34\tcl;C:\Python34\Tools\pynche;C:\Python34\Tools\Scri‌​pts; Any suggestion would be appreciated.I have been using python 3 only so how it would use python 2 interpreter. Commented Jul 9, 2014 at 4:16
  • I don't know Light Table, but if it works like other Python-aware IDEs then there should be a place somewhere in its settings (or the settings for the Python plugin) where you tell it which Python interpreter you want to use. Did you find anything like that? Commented Jul 9, 2014 at 5:54

1 Answer 1

3

I have no idea about the Light Table part, but the error you show is the one that you'd get if you were to somehow try to execute a Python 3 print function call under Python 2 (where print is a statement with a quirky syntax rather than a function). Lines 175-176 of site.py in the Python 3.4 distribution look like this (modulo leading indentation):

print("Error processing line {:d} of {}:\n".format(n+1, fullname),
      file=sys.stderr)

and sure enough, if you try to execute that in a Python 2 interpreter you'll get a SyntaxError, with the cursor pointing to that same = sign:

Python 2.7.8 (default, Jul  3 2014, 06:13:58) 
[GCC 4.2.1 Compatible Apple LLVM 5.1 (clang-503.0.40)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> print("Error processing line {:d} of {}:\n".format(n+1, fullname), file=sys.stderr)
  File "<stdin>", line 1
    print("Error processing line {:d} of {}:\n".format(n+1, fullname), file=sys.stderr)
                                                                           ^
SyntaxError: invalid syntax

I'd suggest looking closely at the settings for the Light Table Python plugin to see if anything's awry. You should also check the setting for your PYTHONPATH environment variable. If it includes a reference to the C:\Python34 directory and you're running Python 2, that could be the cause of the problem. Here's an example of the exact same problem on OS X, caused by starting Python 2 with a PYTHONPATH that refers to Python 3's library directory:

noether:~ mdickinson$ export PYTHONPATH=/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/
noether:~ mdickinson$ python2.7
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site.py", line 176
    file=sys.stderr)
        ^
SyntaxError: invalid syntax
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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.