views:

69

answers:

2

I'm new to Linux, Python and the Anjuta IDE.

I have created a new file called hello.py. This is the contents of that file:

#!/usr/bin/env python
print "Hello World!"

All I want to do is run this in the terminal. I go to Run > Execute but I get the following error message:

Program 'home/joe/Programming/Python//hello.py' does not have execution permission

How do I get this really simple program to run?

Thanks,

+3  A: 

open a shell, cd to the folder where the file is located and execute chmod +x hello.py.

ZeissS
Then you'll need to type `hello.py` to actually run the program.
GreenMatt
@GreenMatt: `./hello.py` unless it's in your PATH
Daenyth
@Daenyth: You're right, good catch. Thanks!
GreenMatt
Thanks for this. On a side note: I wonder why Anjuta doesn't make this happen automatically (since there is a "Run" option for each file it would make sense to automate this).
Garry
+2  A: 

ZeissS' solution will work and is generally preferred to this, but for the sake of completeness, you could also open a shell, cd to the appropriate directory, and type:

python hello.py

GreenMatt
I think he wants to run it from his IDE, which, as I understand from the error, executes the file directly.
ZeissS
@ZeissS: You may be correct, although "All I want to do is run this in the terminal." says to me he wants to run it from a shell prompt. If the attempt is from the IDE, I'd hope it would either be smart enough to run a Python program or configurable enough for an appropriate change to be made. Otherwise, a terminal window may be necessary.
GreenMatt
@GreenMatt: I should have been more clear. I'm used to Xcode and I just wanted to be able to test the file in Anjuta's terminal.
Garry