Results 1 to 5 of 5

Thread: Permission denied in Python when copying files

  1. #1
    Join Date
    May 2008
    Posts
    859

    Permission denied in Python when copying files

    I start in Python and I'm pretty bad in the program in general. Here is my situation:

    Here is the tree:
    C:\MySoft\MyFolder
    C:\Shift

    In MyFolder:
    AppliCommon
    ObjectMetier
    Main

    In Shift:
    AppliCommon
    Main

    The purpose of the script is to update an application that is done by replacing files. Therefore, I must first save and then replace MyFolder by MyFolder files by folders and files in SHIFT. Note that all files contain several sub-folders and files.

    I've done this:
    Code:
    src = r'C:\Shift' 
    dst = r'C:\MySoft\\MyFolder ' 
    for f in os.listdir (src): 
    shutil.copy (os.path.join (src, f), os.path.join (dst, f))
    But I have this error:
    C:\Python26> python.exe "C:\Documents and Settings\Dje\Desktop\depl.py"
    Traceback (most recent call last):
    File "C:\Documents and Settings\Dje\Desktop\depl.py", line 12, in <module>
    shutil.copy (os.path.join (src, f), os.path.join (dst, f))
    File "C:\Python26\lib\shutil.py", line 88, in copy
    CopyFile (src, dst)
    File "C:\Python26\lib\shutil.py", line 52, in CopyFile
    fsrc = open (src, 'rb')
    IOError: [Err no 13] Permission denied: 'C:\\Update\\Main'

  2. #2
    Join Date
    May 2008
    Posts
    2,297

    Re: Permission denied in Python when copying files

    You do not have rights to c:\shift\main.

    Incidentally, shutil has a copytree making a recursive copy alone as a great, no need to make a combo & listdir copy.

  3. #3
    Join Date
    May 2008
    Posts
    859

    Re: Permission denied in Python when copying files

    The problem is that I see no reason why I would have no rights. I am in my local post office, admin, I'm not in a domain, I am owner of the file. For the copytree it seems to me the need for the remote folder does not exist. However, there is, I just updated or I'm wrong?

  4. #4
    Join Date
    May 2008
    Posts
    2,297

    Re: Permission denied in Python when copying files

    Quote Originally Posted by Elijah View Post
    For the copytree it seems to me the need for the remote folder does not exist. However, there is, I just updated or I'm wrong?
    Oh no, actually you're right.

    But if you want "just" sync two folders, you can not use rsync in external process? (or if the files are not too big, you delete the destination and you copytree)

  5. #5
    Join Date
    May 2008
    Posts
    859

    Re: Permission denied in Python when copying files

    These are large files containing several thousand files. I took only 3 files to simplify the example. Basically what I need is get the update file in to replace the files in MyFolder. But I did not update the full records in myaccount only record to be updated.

Similar Threads

  1. Ubuntu, Unable to move files, error: Permission Denied
    By PhanA in forum Operating Systems
    Replies: 5
    Last Post: 10-09-2011, 07:55 AM
  2. Permission denied when opening gamespot
    By thortheviking in forum Software Development
    Replies: 9
    Last Post: 21-05-2010, 12:13 AM
  3. Denied permission to access folders
    By Jack K in forum Vista Help
    Replies: 16
    Last Post: 27-02-2010, 07:18 PM
  4. Access is Denied When Copying NTLDR
    By neuro in forum Hardware Peripherals
    Replies: 2
    Last Post: 19-08-2009, 08:23 PM
  5. Vista and Permission Denied
    By Hamsa! in forum Vista Help
    Replies: 1
    Last Post: 23-02-2008, 10:52 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,035,414.69650 seconds with 16 queries