OSError: [Errno 13] Permission denied

Peter Hansen peter at engcorp.com
Wed Nov 15 07:06:51 CET 2000


jicman wrote:
> 
> Hi all!
> 
> I am trying the following command:
> os.chdir(path)
> file0 = 'file.log'
> file1 = 'file.his'
> os.rename(file0,file1)
> 
> I am getting:
> 
>     os.rename(logname,newname)
> OSError: [Errno 13] Permission denied
> 
> I am able to do this manually in the python interpreter.
> 
> I am running W2000 and I don't know what is w

Not knowing what is w is a common problem amongst W2000 users... ;-)

About the real problem: is it possible that in your actual program, you
have previously opened one of those files?  And not closed it?  When you
do it from the python interpreter, are you executing the same previous
code?  

If I create a file 'file.log' and open it with "f = open('file.log')"
before executing your code above, I get the same message.  

Except for the bizarre line above the OSError message, where you are
showing variables which are no in the code snippet you posted!  Where do
'logname' and 'newname' come from?  I get the impression you are posted
a rather edited version of the real thing, which makes it hard to
troubleshoot.

-- 
Peter Hansen



More information about the Python-list mailing list