"No such image or directory found" PIL Image import



We have recently installed PIL, but when we run the following code the message “no such file or directory: “lena.ppm”” appears.

from PIL import Image
im = Image.open("lena.ppm")

Looking around online the advice is to use an absolute path but how do you do that on here?


With the code you have above, you’re assuming that your lena.ppm file is in the same directory as the python script you’re running. If that file is not in that directory then be sure to put it in that directory and then it should run properly.


How do you view the directory when using Cloud9 (sorry, first time using it)?


Look in the navigation pane on the left where all of your files and folders are shown. From there, be sure those two files are in the same directory.


The only files at the side are my workspaces. There doesn’t seem to be any indication that it has been installed. I tried running the code again to see if it would come up with an error saying that it wasn’t installed, but instead it came up saying there was a syntax error in the first line.

I also tried to run the markdown code from the installing python packages tutorial (having seemingly successfully installed it before trying to install PIL) but it said there was an error in the command import markdown.

Is there somewhere specific I have to get it to save for it be show the files and be accessible by import or something like that?

It’s running python 3, I don’t know if that makes a difference at all.


Share your workspace with me and I’ll see if I can help you out. “Shadowcodex1”


So I logged into your workspace and checked it out. You don’t have an image file uploaded. You can view all files using the file tree on the left which is your workspace.

I added a cat picture to your workspace and told your PIL file to point to it instead. It worked.

Also you should use a .py extension on your files so you get syntax highlighting. I just fixed that for you as well.



Thanks for the help.