Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Image.open no such file or directory #7197

Closed
juliuseizure opened this issue Jun 3, 2023 · 3 comments
Closed

Image.open no such file or directory #7197

juliuseizure opened this issue Jun 3, 2023 · 3 comments
Labels

Comments

@juliuseizure
Copy link

I posted this in discussion, but maybe it is more appropriate here:

I have been working with some starter code and have run into a snag.

I am using Image.open() to import one of the example images (cat.jpg in this case). Instead I get FileNotFoundError: [Errno 2] No such file or directory: 'cat.jpg'

I dug into a different example I found online, and theirs gave a path to the image: Image.open('data/src/lena.jpg'). Running that gives the same error. In this case, yes, I found src (https://github.com/python-pillow/Pillow/tree/main/src), but that doesn't contain any images. I did find some in https://github.com/python-pillow/Pillow/blob/main/Tests/images/. Is this the new path we should be using? EDIT: trying Image.open("Tests/images/hopper.jpg") gives the same error.

@Yay295
Copy link
Contributor

Yay295 commented Jun 3, 2023

Opening an image with Pillow works the same as opening a file with basic Python. If you give an absolute path it will try to load an image from the file at that path; if you give a relative path it will try to load an image from the file at the relative location to your current location.

@aclark4life
Copy link
Member

Is this the new path we should be using? EDIT: trying Image.open("Tests/images/hopper.jpg") gives the same error.

What is the fully qualified file system path to cat.jpg?

Once you know that, then you can try Image.open('/the/fully/qualified/local/file/system/path/to/cat.jpg')

@juliuseizure
Copy link
Author

Thank you. Resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants