Question

I'd been running code on my Windows desktop using Anaconda and 3.3.1. All good. Everything works.

When I tried running it on my laptop (also Windows, running the same versions), I keep getting SyntaxError: invalid syntax for anything I write. For example:

print ("Hello World")

>>> runfile(r'C:\Users\Laptopname\Desktop\.temp.py', wdir=r'C:\Users\Laptopname\Desktop')
  File "<stdin>", line 1
    runfile(r'C:\Users\Laptopname\Desktop\.temp.py', wdir=r'C:\Users\Laptopname\Desktop')
                             ^
SyntaxError: invalid syntax

When I run it in IDLE, however, it works fine.

There's something wrong, I think, with the settings on Spyder. Any ideas?

Was it helpful?

Solution

This is not an answer, only an extended comment:

Open up a python interactive interpreter and type

with open(r'C:\Users\Laptopname\Desktop\.temp.py', 'rb') as f:
    print(repr(f.read()))

Please post the output. (This will show us exactly what is in the file.)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top