0

I have made a python code that takes a screenshot and saves it. Am facing the following Error in saving a piece of code:

"site-packages\PIL\image.py",line 2131, in save...PermissionError:[error 13] permission denied: scr.png

Note

Folder permission is set to read/write.

Piece of code:

snapshot = ImageGrab.grab()

    # Using png because it cannot write mode RGBA as JPEG
    file = "scr.png"
    snapshot.save(file)
bad_coder
  • 11,289
  • 20
  • 44
  • 72
zain
  • 19
  • 7
  • 2
    "folder permission is set to read/write." Are you certain you know which folder it's attempting to save to? Are you certain that's the folder whose permissions you checked? The [current working directory](https://stackoverflow.com/questions/5137497/find-current-directory-and-files-directory) can be unintuitive. – Karl Knechtel Jun 20 '20 at 05:23
  • You shouldn't be writing your image files to that directory. It's for scripts installed as part of Pillow. – Mike Housky Jun 20 '20 at 05:25
  • It looks like you might have changed directories to run a script from that folder. If so, I suggest that you don't. Or, use an explicit path to a directory you own. ex: file = r'C:\Users\yourname\Documents\scr.png' Using a r' raw string lets you use \ in the string without doubling each one. – Mike Housky Jun 20 '20 at 05:34

2 Answers2

0

Move your code to desktop, then your code will automatically work.

Move your code out of Site-Packages to Desktop or somewhere
Vignesh
  • 1,553
  • 1
  • 10
  • 25
0

Try in another directory and put the full path of the image file:

file = "path/to/img/scr.png"

or try with sudo or admin prompt

Hugo LB
  • 158
  • 5