Reputation: 25
The pillow library won't open an image in the same directory as the script anymore, while it used to. I haven't changed anything to do with how the file is loaded. I of course have the jpg in the folder with the script while I'm testing it.
I've tried the import to all three of these since I've read that works:
from PIL import Image
import PIL.Image
import PIL
None of these have worked and the output is
FileNotFoundError: [Errno 2] No such file or directory: 'pic.jpg'
The code loading the image is:
def main(new_width=300):
try:
image = PIL.Image.open("pic.jpg")
except:
print("Please rename the file to 'pic.jpg' and restart the script")
quit()
Upvotes: 1
Views: 1417
Reputation: 69396
Try using the absolute path to the image
from PIL import Image
try:
image = Image.open("/path/to/pic.jpg")
except:
print("Please rename the file to 'pic.jpg' and restart the script")
quit()
Upvotes: 2