473,372 Members | 1,040 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,372 software developers and data experts.

shutil: permission denied errors on windows

Google tells quite some things about it, but none of them are satisfactory.

I'm on Windows, and shutil operations (e.g. move, copy) throw [Errno 13]
Permission denied all the time, for the source files. It seems that this
is the case for all my files. But what I don't understand is that
yesterday it still worked. I didn't change anything on my system though
(at least not that I am aware of). I restarted the computer several
times to see if that helped, but it didn't. Also I can't find a process
that would be using the files...

Has anybody experienced this problem before, or have a solution?

Kind regards,
antoine

Here's the code that throws the errors

[...]
for l in files:
from_file = os.path.join(dir, l)
to_file = from_file.replace(tree_top, backup_dir)
try:
if not os.path.exists(to_file):
log('Copying new %s' % from_file)
counter_new += 1
shutil.copy2(from_file, to_file)
elif int(os.path.getmtime(from_file)) >
int(os.path.getmtime(to_file)):
log('Copying modified %s' % from_file)
counter_mod += 1
shutil.copy2(from_file, to_file)
elif os.path.getsize(from_file) os.path.getsize(to_file):
log('Sizes differ, but not rest: Copying %s' %
from_file)
counter_special += 1
shutil.copy2(from_file, to_file)
elif os.path.getsize(from_file) < os.path.getsize(to_file):
log('Orig file smaller than backup file: Copying
%s' % from_file)
counter_special += 1
shutil.copy2(to_file, backup_dir+'DIFF_SIZE')
shutil.copy2(from_file, to_file)
else:
#log('not treated: %s' % l)
pass

except (OSError, IOError), e:
not_accessible += 1
print e
[...]
Nov 6 '06 #1
6 14518
I use the copy function a lot and never have problem. I suggest that
you write a no brainer standalone test code and if it still fails
there, then you have a problem with your installation.

Antoine De Groote wrote:
Google tells quite some things about it, but none of them are satisfactory.

I'm on Windows, and shutil operations (e.g. move, copy) throw [Errno 13]
Permission denied all the time, for the source files. It seems that this
is the case for all my files. But what I don't understand is that
yesterday it still worked. I didn't change anything on my system though
(at least not that I am aware of). I restarted the computer several
times to see if that helped, but it didn't. Also I can't find a process
that would be using the files...

Has anybody experienced this problem before, or have a solution?

Kind regards,
antoine

Here's the code that throws the errors

[...]
for l in files:
from_file = os.path.join(dir, l)
to_file = from_file.replace(tree_top, backup_dir)
try:
if not os.path.exists(to_file):
log('Copying new %s' % from_file)
counter_new += 1
shutil.copy2(from_file, to_file)
elif int(os.path.getmtime(from_file)) >
int(os.path.getmtime(to_file)):
log('Copying modified %s' % from_file)
counter_mod += 1
shutil.copy2(from_file, to_file)
elif os.path.getsize(from_file) os.path.getsize(to_file):
log('Sizes differ, but not rest: Copying %s' %
from_file)
counter_special += 1
shutil.copy2(from_file, to_file)
elif os.path.getsize(from_file) < os.path.getsize(to_file):
log('Orig file smaller than backup file: Copying
%s' % from_file)
counter_special += 1
shutil.copy2(to_file, backup_dir+'DIFF_SIZE')
shutil.copy2(from_file, to_file)
else:
#log('not treated: %s' % l)
pass

except (OSError, IOError), e:
not_accessible += 1
print e
[...]
Nov 7 '06 #2
Yes it's strange, I never had the problem before, either. It seems now
to be only the case for folders. A very simple

shutil.copy('a', 'b')

already fails with the error message.

I reinstalled Python, but that didn't change anything...

Regards,
antoine

John Henry wrote:
I use the copy function a lot and never have problem. I suggest that
you write a no brainer standalone test code and if it still fails
there, then you have a problem with your installation.

Antoine De Groote wrote:
>Google tells quite some things about it, but none of them are satisfactory.

I'm on Windows, and shutil operations (e.g. move, copy) throw [Errno 13]
Permission denied all the time, for the source files. It seems that this
is the case for all my files. But what I don't understand is that
yesterday it still worked. I didn't change anything on my system though
(at least not that I am aware of). I restarted the computer several
times to see if that helped, but it didn't. Also I can't find a process
that would be using the files...

Has anybody experienced this problem before, or have a solution?

Kind regards,
antoine

Here's the code that throws the errors

[...]
for l in files:
from_file = os.path.join(dir, l)
to_file = from_file.replace(tree_top, backup_dir)
try:
if not os.path.exists(to_file):
log('Copying new %s' % from_file)
counter_new += 1
shutil.copy2(from_file, to_file)
elif int(os.path.getmtime(from_file)) >
int(os.path.getmtime(to_file)):
log('Copying modified %s' % from_file)
counter_mod += 1
shutil.copy2(from_file, to_file)
elif os.path.getsize(from_file) os.path.getsize(to_file):
log('Sizes differ, but not rest: Copying %s' %
from_file)
counter_special += 1
shutil.copy2(from_file, to_file)
elif os.path.getsize(from_file) < os.path.getsize(to_file):
log('Orig file smaller than backup file: Copying
%s' % from_file)
counter_special += 1
shutil.copy2(to_file, backup_dir+'DIFF_SIZE')
shutil.copy2(from_file, to_file)
else:
#log('not treated: %s' % l)
pass

except (OSError, IOError), e:
not_accessible += 1
print e
[...]
Nov 7 '06 #3

Antoine De Groote schrieb:
Yes it's strange, I never had the problem before, either. It seems now
to be only the case for folders. A very simple

shutil.copy('a', 'b')

already fails with the error message.

I reinstalled Python, but that didn't change anything...

Regards,
antoine
Just a guess, update you virus scanner. Maybe someone sits in the back
and doesn't like what you are doing.

Regards Jürgen

Nov 7 '06 #4
Okay, it's always good that strange things are repeatable and happens
with simple scripts.

Are you saying "a" is a folder? So, the failure is only with copying
folder? Not individual file?

Antoine De Groote wrote:
Yes it's strange, I never had the problem before, either. It seems now
to be only the case for folders. A very simple

shutil.copy('a', 'b')

already fails with the error message.

I reinstalled Python, but that didn't change anything...

Regards,
antoine

John Henry wrote:
I use the copy function a lot and never have problem. I suggest that
you write a no brainer standalone test code and if it still fails
there, then you have a problem with your installation.

Antoine De Groote wrote:
Google tells quite some things about it, but none of them are satisfactory.

I'm on Windows, and shutil operations (e.g. move, copy) throw [Errno 13]
Permission denied all the time, for the source files. It seems that this
is the case for all my files. But what I don't understand is that
yesterday it still worked. I didn't change anything on my system though
(at least not that I am aware of). I restarted the computer several
times to see if that helped, but it didn't. Also I can't find a process
that would be using the files...

Has anybody experienced this problem before, or have a solution?

Kind regards,
antoine

Here's the code that throws the errors

[...]
for l in files:
from_file = os.path.join(dir, l)
to_file = from_file.replace(tree_top, backup_dir)
try:
if not os.path.exists(to_file):
log('Copying new %s' % from_file)
counter_new += 1
shutil.copy2(from_file, to_file)
elif int(os.path.getmtime(from_file)) >
int(os.path.getmtime(to_file)):
log('Copying modified %s' % from_file)
counter_mod += 1
shutil.copy2(from_file, to_file)
elif os.path.getsize(from_file) os.path.getsize(to_file):
log('Sizes differ, but not rest: Copying %s' %
from_file)
counter_special += 1
shutil.copy2(from_file, to_file)
elif os.path.getsize(from_file) < os.path.getsize(to_file):
log('Orig file smaller than backup file: Copying
%s' % from_file)
counter_special += 1
shutil.copy2(to_file, backup_dir+'DIFF_SIZE')
shutil.copy2(from_file, to_file)
else:
#log('not treated: %s' % l)
pass

except (OSError, IOError), e:
not_accessible += 1
print e
[...]
Nov 7 '06 #5
Yes, that's exactly what was the case... But see my other post, that
straightens things up...

Thanks!
antoine
John Henry wrote:
Okay, it's always good that strange things are repeatable and happens
with simple scripts.

Are you saying "a" is a folder? So, the failure is only with copying
folder? Not individual file?

Antoine De Groote wrote:
>Yes it's strange, I never had the problem before, either. It seems now
to be only the case for folders. A very simple

shutil.copy('a', 'b')

already fails with the error message.

I reinstalled Python, but that didn't change anything...

Regards,
antoine

John Henry wrote:
>>I use the copy function a lot and never have problem. I suggest that
you write a no brainer standalone test code and if it still fails
there, then you have a problem with your installation.

Antoine De Groote wrote:
Google tells quite some things about it, but none of them are satisfactory.

I'm on Windows, and shutil operations (e.g. move, copy) throw [Errno 13]
Permission denied all the time, for the source files. It seems that this
is the case for all my files. But what I don't understand is that
yesterday it still worked. I didn't change anything on my system though
(at least not that I am aware of). I restarted the computer several
times to see if that helped, but it didn't. Also I can't find a process
that would be using the files...

Has anybody experienced this problem before, or have a solution?

Kind regards,
antoine

Here's the code that throws the errors

[...]
for l in files:
from_file = os.path.join(dir, l)
to_file = from_file.replace(tree_top, backup_dir)
try:
if not os.path.exists(to_file):
log('Copying new %s' % from_file)
counter_new += 1
shutil.copy2(from_file, to_file)
elif int(os.path.getmtime(from_file)) >
int(os.path.getmtime(to_file)):
log('Copying modified %s' % from_file)
counter_mod += 1
shutil.copy2(from_file, to_file)
elif os.path.getsize(from_file) os.path.getsize(to_file):
log('Sizes differ, but not rest: Copying %s' %
from_file)
counter_special += 1
shutil.copy2(from_file, to_file)
elif os.path.getsize(from_file) < os.path.getsize(to_file):
log('Orig file smaller than backup file: Copying
%s' % from_file)
counter_special += 1
shutil.copy2(to_file, backup_dir+'DIFF_SIZE')
shutil.copy2(from_file, to_file)
else:
#log('not treated: %s' % l)
pass

except (OSError, IOError), e:
not_accessible += 1
print e
[...]
Nov 7 '06 #6
Thanks for your replies, guys. I found the problem now.

Actually the problem arised just before the code that I had in my
original post.

Here are the 2 lines that mess things up. It's those that are commented
out. If not commented, the errors were raised.

Clearly there is an error in the second line. It includes subdirs and s
instead of files and f. Took me 2 days to finally see it.

for dir, subdirs, files in os.walk(tree_top):

# subdirs[:] = [s for s in subdirs if
os.path.join(dir,s).replace('\\', '/') not in excluded]
# files[:] = [f for f in subdirs if
os.path.join(dir,s).replace('\\', '/') not in excluded]

for s in subdirs:
bak_sub = os.path.join(dir, s).replace(tree_top, backup_dir)
if not os.path.exists(bak_sub):
log('Creating directory %s' % bak_sub)
os.mkdir(bak_sub)

for l in files:
[code pasted earlier]...

But what still beats me is why my minimal example with folders 'a' and
'b' didn't work... It was independent of this code...

Anyway, my program works now, and that's for the moment the most
important thing.

Regards,
antoine

John Henry wrote:
I use the copy function a lot and never have problem. I suggest that
you write a no brainer standalone test code and if it still fails
there, then you have a problem with your installation.

Antoine De Groote wrote:
>Google tells quite some things about it, but none of them are satisfactory.

I'm on Windows, and shutil operations (e.g. move, copy) throw [Errno 13]
Permission denied all the time, for the source files. It seems that this
is the case for all my files. But what I don't understand is that
yesterday it still worked. I didn't change anything on my system though
(at least not that I am aware of). I restarted the computer several
times to see if that helped, but it didn't. Also I can't find a process
that would be using the files...

Has anybody experienced this problem before, or have a solution?

Kind regards,
antoine

Here's the code that throws the errors

[...]
for l in files:
from_file = os.path.join(dir, l)
to_file = from_file.replace(tree_top, backup_dir)
try:
if not os.path.exists(to_file):
log('Copying new %s' % from_file)
counter_new += 1
shutil.copy2(from_file, to_file)
elif int(os.path.getmtime(from_file)) >
int(os.path.getmtime(to_file)):
log('Copying modified %s' % from_file)
counter_mod += 1
shutil.copy2(from_file, to_file)
elif os.path.getsize(from_file) os.path.getsize(to_file):
log('Sizes differ, but not rest: Copying %s' %
from_file)
counter_special += 1
shutil.copy2(from_file, to_file)
elif os.path.getsize(from_file) < os.path.getsize(to_file):
log('Orig file smaller than backup file: Copying
%s' % from_file)
counter_special += 1
shutil.copy2(to_file, backup_dir+'DIFF_SIZE')
shutil.copy2(from_file, to_file)
else:
#log('not treated: %s' % l)
pass

except (OSError, IOError), e:
not_accessible += 1
print e
[...]
Nov 7 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Nick | last post by:
OK Guys and Gals, I've got a script that does some work with the document object in another frame. This works fine until the other frame contains a document on another domain. This of course...
2
by: PM Creyghton | last post by:
I got this error without using frames: First of all, I'm developing an ASP application, and once in a while my activeX components crash or hang, I got page-not-found errors, errors generated by...
1
by: Nathan | last post by:
We are encountering strange errors using IE 6 with a specified automatic configuration script and an internal ASP.NET application. The application performs very oddly throwing JavaScript errors...
1
by: Mr.KisS | last post by:
Hi, In my aspx page i use a stocked procedure and in this procedure, there is a SELECT query. And whene the aspx page calls the procedure i get this exception : ...
11
by: Alec Wysoker | last post by:
Using Python 2.3.5 on Windows XP, I occasionally get OSError: Permission denied when calling os.remove(). This can occur with a file that is not used by any other process on the machine, and is...
4
by: zombek | last post by:
I'm making a small program which takes a folder with images and generates optimized normal-sized images and thumbnails using Python Imaging Lbrary (PIL). The problem is here: ........
21
by: alistair_henderson | last post by:
Morning All, I have some code for a website which uses 'window.open' to simulate modal dialog boxes. I use the window.closed property to decide if the window object exists at various points. ...
3
by: unauthorized | last post by:
I'm running a PHP 5.1 on an Apache 2.2 server under Windows XP which I use to develop my web apps. Currently, I am trying to add "upload" functionality to my project, but for some reason, when the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.