2 Replies Latest reply on Mar 22, 2019 12:38 AM by ysivelip

    Simple Python Question

    ysivelip

      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: Code:     #!/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

        • Re: Simple Python Question
          gecoz

          Hi Carlos,

           

          Looks like your IDE is trying to run your code as a script, which means it is trying to launch the file as an executable. In Linux, files have got permissions associated with them, i.e. files can be readable, writeable and/or executable. For a file to be able to be executed as script, the file itself needs to have executable permission, and this is probably what is missing in your set up (newly created files usually only get read/write permissions).

           

          To fix that, you need to make your file executable, by giving it executable permission. This can be done using the chmod command, like this:

           

          chmod u+x home/joe/Programming/Python/hello.py

           

           

          Once run the above command, try "Run>Execute" again in your IDE, and it should work.

           

           

          Fabio

          4 of 4 people found this helpful
          • Re: Simple Python Question
            ysivelip

            Thanks Fabio

            "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: Code:     #!/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?"

            Any other advice??

            Thanks

            IT rate