How to fix PermissionError: [Errno 13] Permission denied in python? (win10)

644 Views Asked by At

I'm trying to resize images in the folder in a folder named "test_09".

import PIL
import os
from PIL import Image

f = rb'test_09/'
for folder in os.listdir(f):
    f_folder = f
    for file in os.listdir(f_folder):
        f_img = f_folder + file
        img = Image.open(f_img)
        img = img.resize((300, 400))
        img.save(f_img)

The error message:

Traceback (most recent call last): File "h:\image-resizing.py", line 11, in <module> img = Image.open(f_img) File "C:\Users\usernamee\AppData\Local\Programs\Python\Python38\lib\site-packages\PIL\Image.py", line 2878, in open fp = builtins.open(filename, "rb") PermissionError: [Errno 13] Permission denied: 'test_09/L01'

Before posting this question, I already changed the folder permission to F by using icacls in window cmd. Note: All of these mentioned actions were done by using run as administrator.

0

There are 0 best solutions below