Aggie64
Posts: 8
Joined: Wed Mar 05, 2014 5:59 pm

Saving Python File

Wed Mar 05, 2014 6:11 pm

Last week, I created a python file named Blink.py and was able to save it to my directory home/wallis/Blink.py.
Now, I can open the file in python, but when I try to save the file, I get the following error:

[Errno 13] Permission denied:
'/home/wallis/Blink.py'

I would appreciated any help on what I am doing wrong.

Thanks

User avatar
elParaguayo
Posts: 1943
Joined: Wed May 16, 2012 12:46 pm
Location: London, UK

Re: Saving Python File

Wed Mar 05, 2014 7:18 pm

Can you show the output of:

Code: Select all

ls -l /home/wallis/Blink.py
RPi Information Screen: plugin based system for displaying weather, travel information, football scores etc.

Aggie64
Posts: 8
Joined: Wed Mar 05, 2014 5:59 pm

Re: Saving Python File

Wed Mar 05, 2014 7:51 pm

elParaguayo wrote:Can you show the output of:

Code: Select all

ls -l /home/wallis/Blink.py
Here is what was listed
-rw-r--r-- l wallis wallis 210 Feb 12 07:38 /home/wallis/Blink.py

User avatar
DougieLawson
Posts: 39304
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Saving Python File

Wed Mar 05, 2014 7:57 pm

The file doesn't have the --x bits set.
chmod 0755 /home/wallis/Blink.py

Also the first line needs
#!/usr/bin/python
or
#!/use/bin/python3

Depending what flavour of python you're writing.
As long as you are logged in as wallis or using root you can write to that file.

sudo nano ... will work.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

Aggie64
Posts: 8
Joined: Wed Mar 05, 2014 5:59 pm

Re: Saving Python File

Wed Mar 05, 2014 8:06 pm

I am using IDLE3 as the editor where I originally created and saved a python file that now gives me the Error 13.

User avatar
DougieLawson
Posts: 39304
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Saving Python File

Wed Mar 05, 2014 8:10 pm

sudo idle3

That runs idle with root permissions.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

Aggie64
Posts: 8
Joined: Wed Mar 05, 2014 5:59 pm

Re: Saving Python File

Wed Mar 05, 2014 8:40 pm

I tried sudo idle3 and that lets me save the file. I was starting idle3 form the icon on the gui screen before. I am new to linux and the Raspberry pi and I know my issue is a file permissions problem and I will work on this, but in th emeantime I can continue to experiment with my Raspberry pi.

I tried the chmod from a reply i received and it chaned the permissions to:
-rwxr-xr--s l , but I still could not save the file without getting the Errno 13 until i tried sudo idle3.

Thanks guys for helping a beginner.
Wallis

User avatar
DougieLawson
Posts: 39304
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Saving Python File

Wed Mar 05, 2014 8:47 pm

Can you post the output from
ls -laR /home/wallis
and
grep -e 'wallis' /etc/passwd
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

Aggie64
Posts: 8
Joined: Wed Mar 05, 2014 5:59 pm

Re: Saving Python File

Wed Mar 05, 2014 11:09 pm

Here is the response from ls -laR /home/wallis

drwxr-xr-x 2 wallis wallis 4096 Mar 5 14:45 .
drwxr-xr-x 4 root root 4096 Feb 12 07:26 ..
-rw------- 1 wallis wallis 866 Mar 5 14:08 .bash_history
-rw-r--r-- 1 wallis wallis 220 Jan 10 20:13 .bash_logout
-rw-r--r-- 1 wallis wallis 3243 Sep 25 1522 .bashrc
-rwxr-xr-x 1 wallis wallis 210 Mar 5 14:32 Blink.py
-rw-r--r-- 1 root root 108 Mar 5 16:48 Motion.py
lrwxrwxrwx 1 wallis wallis 44 Dec 311969 pistore.desktop -> /usr/share/indiecity/pistore/pistore/desktop
-rw-r--r-- 1 wallis wallis 675 Jan 10 2013 .profile

Output from grep -e 'wallis' /etc/passwd
wallis:x:1001:1004::/home/wallis:/bin/bash

I had to hand type the above, so the character alignment is not exactly correct.
Thanks for helping me.

User avatar
DougieLawson
Posts: 39304
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Saving Python File

Wed Mar 05, 2014 11:34 pm

If you're logged in a wallis then there is no reason why you can't read, write or execute your Blink.py program.
I can only assume that your GUI isn't logged in a willis.

Open a LXterminal window and try the whoami command.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

Aggie64
Posts: 8
Joined: Wed Mar 05, 2014 5:59 pm

Re: Saving Python File

Thu Mar 06, 2014 12:32 am

I went to a terminal window and typed the following:
pi@raspberrypi ~ whoami
pi
pi@raspberrypi ~ su wallis
Password: (entered my password)
wallis@raspberrypi /home/pi $ whoami
wallis
wallis@raspberrypi /home/pi $ cd /home/wallis
wallis@raspberrypi ~ $

I then opened idle 3 from its GUI icon and opened my Blink.py file from the /home/wallis directory and when I try to save the file I still get the Error 13 Permission Denied.
Thanks again

User avatar
DougieLawson
Posts: 39304
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Saving Python File

Thu Mar 06, 2014 10:02 am

Log out completely.
Login from the prompt as wallis
startx

If you want to change who is logged on by default
sudo nano /etc/lightdm/lightdm.conf
find the line with -user=pi and change that to -user=wallis
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

Aggie64
Posts: 8
Joined: Wed Mar 05, 2014 5:59 pm

Re: Saving Python File

Thu Mar 06, 2014 6:59 pm

I logged out and then logged in as wallis and when i typed startx, my screen went black for about 10 seconds and then i got the raspberry gui screen with the raspberry in the middle of the screen, but all my icons such as LXTeminal are gone. There are no icons on the screen.

Thanks again.

User avatar
DougieLawson
Posts: 39304
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Saving Python File

Thu Mar 06, 2014 10:09 pm

sudo cp -R /home/pi/Desktop /home/wallis/Desktop
find /home/wallis/Desktop | xargs sudo chown wallis

Should give you all the same icons as your pi id.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

Aggie64
Posts: 8
Joined: Wed Mar 05, 2014 5:59 pm

Re: Saving Python File

Fri Mar 07, 2014 4:45 pm

Dougie,
I ran the commands you gave me to copy the pi desktop to my wallis user desktop. I then went back and did what you stated earlier

I logged out completely
logged in from the prompt as wallis
startx
sudo nano /etc/lightdm/lighttdm.conf
This time it said new file and as expected there were no lines in the file.

I really know nothing about Linux, so for now I will just stick to running my raspberry as the pi user and start learning more abut Linux and then try switching over to my user name.

I really appreciate the time you have taken to help a beginner on Linux. I know I will be posting more questions on the forum.
Wallis

Return to “Python”