-1

I have a file called gameover.py in a folder called python which is in my documents. When I try to run it in the terminal via the command:

python gameover.py

I get this:

/Library/Frameworks/Python.framework/Versions/2.5/Resources/Python.app/Contents/MacOS/Python: can't open file 'gameover.py': [Errno 2] No such file or directory

Edit: I tried this:

$ cd ~/Documents/python
$ python gameover.py

and I get this error:

File "gameover.py", line 1
Python 3.3.3 (v3.3.3:c3896275c0f6, Nov 16 2013, 23:39:35) 
         ^
SyntaxError: invalid syntax

Please help!

stiemannkj1
  • 4,418
  • 3
  • 25
  • 45
SnakeEyes
  • 1,257
  • 3
  • 9
  • 5
  • 1
    Did you cd to the directory with the .py file first? – Wooble Feb 01 '14 at 00:14
  • `/Library/Frameworks/Python.framework/Versions/2.5/Resources/Python.app/Contents/MacOS/Python` is that where `gameover.py` is located? – kylieCatt Feb 01 '14 at 00:15
  • @Wooble possible duplicate? whos the OP in both posts? – markcial Feb 01 '14 at 00:27
  • 1
    Umm, that's an automatically generated message with my close vote. – Wooble Feb 01 '14 at 00:28
  • ah didn't knew that, i have not enough karma :P nice to know – markcial Feb 01 '14 at 00:31
  • @SnakeEyes, That second error you are getting means that you are running the program correctly. However, your python script has a syntax error and you need to do what others are suggesting and learn how to do python. Anyway, you should accept as your answer whoever explained how you should `cd` into the correct directory, and run python correctly. – stiemannkj1 Feb 01 '14 at 01:51

2 Answers2

1

The problem is that gameover.py is not in your working directory. Assuming that by "a file called gameover.py in a folder called python which is in my documents" means the file's path is /Users/username/Documents/python/gameover.py, you can run it entering python ~/Documents/python/gameover.py or cd ~/Documents/python; python gameover.py

weitzner
  • 440
  • 3
  • 12
1

Not an answer to your question exactly but just to try and help you out until you get the hang of terminal, you can run files directly from the Python IDLE by opening the file from IDLE (File > Open) and pressing F5.

kylieCatt
  • 10,672
  • 5
  • 43
  • 51