# Get .webpfile
for file in os.listdir(selected_folder):
if file.endswith(".webp"):
webp_path = os.path.join(selected_folder, file)
webp_name = os.path.join(file)
# Convert .webp to .jpg because YouTube doesn't like .webp :/
im = Image.open(webp_path).convert("RGB")
im.save(webp_path + ".jpg","jpeg")
I'm getting
local variable 'webp_path' referenced before assignment
and if I put global, it says that webp_path doesn't exist
webp_pathonly exists if yourifcondition is true. It likely isn't, meaning it is being referenced before assignment.webp_pathis defined only if certain conditions are met. ButImage.open(webp_path)is executed regardless of whether it is defined or not. Hence the error