3

I got this when I tried to open a .py file on the terminal line I edited in pico:

lightning@rigel5:~$ ./hello.py
bash: ./hello.py: Permission denied

How can I easily open a .py file from the pico editor in the terminal and run it in the python interpreter?

10
  • Where is the file located? Did you create the file you are trying to run? – jobin Mar 16 '13 at 2:24
  • As I can see, in the command that you are entering, you're trying to run it but not edit it. Normally, you can to open the file with the editor that you want to, adding the file as a parameter. e.g. using the Geany editor: geany main.c – Lucio Mar 16 '13 at 2:59
  • yes I created it and it is in the Home folder – lightning Mar 16 '13 at 3:08
  • 1
    use chmod 755 command – microarm15 Mar 16 '13 at 3:09
  • 1
    @lightning You has marked question as solved by marking the answer as accepted. So, is not necessary to add it to the title. – Lucio Mar 16 '13 at 3:33
2

How to open the file with Pico:

In the terminal enter pico file where file is the path and the name of the file that you're trying to open with the editor.

How to run the python script from terminal:

There are a couples of ways to do it, one of them is:

  1. Give execution permissions to the file entering chmod +x file.py
  2. Run the script with ./file.py

Another way is using the python interpreter:

  1. Enter python file.py

NOTE: In all commands replace file with your're file name

0
1

if your file is in home, use

sudo chmod 755 "your_file.py"
./"your_file.py"
4
  • 1
    what does the 755 mean, Microarm? – lightning Mar 16 '13 at 3:27
  • thanks microarm, been having problems with this and can now use this question to practice – lightning Mar 16 '13 at 3:29
  • the numeric notation is used to change the permission for a certain file for owner, group and others.. you may google for it if you are interested – microarm15 Mar 16 '13 at 3:34
  • To be precise, 755 means: the user can RWX, the group and others can RX. Where R=read, W=write and X=execute. – Lucio Mar 16 '13 at 3:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.