file write operations produces IOError errno13 permission denied

29 views
Skip to first unread message

Hani

unread,
Jul 31, 2008, 11:53:27 AM7/31/08
to Django users
Hi,

I'm a Python and Django newbie. I have searched about this issue and
found nothing.

I have a simple Django app where I want to write to a file when
certain steps have occurred.

When the following line of code is reached:

logstep=open(filename,'a')

an IOError, error 13, permission denied is produced.

Any insight as to why this may happen would be greatly appreciated.

BTW, this works fine from the shell.

Thanks,
Hani

Martin Diers

unread,
Jul 31, 2008, 12:22:04 PM7/31/08
to django...@googlegroups.com
Probably because your web server process does not have write
permissions to the file / directory in question?

Are you running from the shell as the same user that is running your
code in the webserver?

Hani

unread,
Jul 31, 2008, 1:36:32 PM7/31/08
to Django users
This is on my ubuntu machine at home. I am not sure what user is
running the code in the webserver but I would assume it's the same
user ( I don't know that much about linux permissions).

Thanks,
Hani

Hani

unread,
Jul 31, 2008, 1:39:18 PM7/31/08
to Django users
Martin,

I think you solved it.

I added a path to the /tmp folder and the error went away and it
started writing to the file.

Thanks,
Hani

On Jul 31, 12:22 pm, Martin Diers <mar...@diers.us> wrote:

Martin Diers

unread,
Jul 31, 2008, 1:57:23 PM7/31/08
to django...@googlegroups.com
If you are running the development server (./manage.py runserver),
then you are correct, it should be running under your user account.

If, however, you are running under a web server, such as Apache, then
it will be running under the Apache user's account.

Any process can write to /tmp, so that of course should always work,
but it's not the best place to put log files.

Presuming you are running the development server, I would check to
make absolutely sure the filename string is what you expect it to be.
You can easily check this by adding a "print filename" above that line
of code, and checking the dev server's console.

James Matthews

unread,
Jul 31, 2008, 2:33:56 PM7/31/08
to django...@googlegroups.com

Gwyn Evans

unread,
Jul 31, 2008, 3:36:09 PM7/31/08
to django...@googlegroups.com
Another useful thing with the development server is the ability to
just add "import pdb; pdb.set_trace()" in a view function to break to
the debugger!

/Gwyn

Reply all
Reply to author
Forward
0 new messages