简体   繁体   English

IOError:[Errno 13]权限被拒绝

[英]IOError: [Errno 13] Permission denied

I'm getting a permission error when trying to save a screenshot from Sikuli under Windows. 我试图在Windows下从Sikuli保存屏幕截图时收到权限错误。 The code that's doing the capturing is: 正在进行捕获的代码是:

def CaptureScreenshot(self):
    resultsDirectory = os.path.join('C','08 May 2013 11 34','myname.png')
    screenshot = capture(self.screen)
    print(screenshot)
    shutil.move(screenshot,self.resultsDirectory)

When I print the screenshot path returned by capture , I get 当我打印capture返回的屏幕截图路径时,我得到了

D:\DOCUME~1\BUNNINGS\LOCALS~1\Temp\sikuli-scr-366782306192033926.png

When I run the code, I get this error: 当我运行代码时,我收到此错误:

Traceback (most recent call last):
  File "__pyclasspath__/Tests/Tests.py", line 12, in tearDown
  File "__pyclasspath__/Scripts/Screen.py", line 39, in CaptureScreenshot
  File "C:\jython2.5.3\Lib\shutil.py", line 205, in move
    copy2(src,dst)
  File "C:\jython2.5.3\Lib\shutil.py", line 96, in copy2
    copyfile(src, dst)
  File "C:\jython2.5.3\Lib\shutil.py", line 52, in copyfile
    fdst = open(dst, 'wb')
IOError: [Errno 13] Permission denied: 'C\\08 May 2013 11 34\\myname.png'

The destination folder exists and myname.png is the new name I am trying to give to the image. 目标文件夹存在, myname.png是我试图给图像的新名称。

I noticed that the destination folder's properties are set to "read only". 我注意到目标文件夹的属性设置为“只读”。 Is this causing the issue? 这会导致问题吗? I couldn't change the readonly attribute; 我无法更改readonly属性; when I try, it just goes back to readonly. 当我尝试时,它只是回到readonly。

There seems to be a colon missing after the C in your path. 在您的路径中C之后似乎缺少一个冒号。 You are now trying to write in a subdirectory 'C' of the current directory. 您现在正在尝试写入当前目录的子目录“C”。

Try to change the second line into: 尝试将第二行更改为:

resultsDirectory = os.path.join('C:','08 May 2013 11 34','myname.png')
                                  ^

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM