简体   繁体   中英

Python Script not executing in Light Table shows error

Help! i am getting this error again and again....on light table while im 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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM