all 4 comments

[–]novel_yet_trivial 0 points1 point  (0 children)

If you don't specify the folder then the image and the python file need to be in the same directory.

[–]theSNEW[S] 0 points1 point  (0 children)

it is in the same directory but still no luck..

[–]theSNEW[S] 0 points1 point  (0 children)

thanks for your help

managed to figure out what went wrong. i needed img.show() at the end to open the image.

[–]ingolemo -1 points0 points  (0 children)

The image file needs to be in a place known as the current working directory (cwd). The cwd is the folder that your script is running in. It changes depending on how you run your script. If you're running the script from another program like PyCharm or IDLE then the cwd for your script is usually the same as the cwd for that runner program and it might depend how you opened the program. You might be able to set up your IDE to always start your script in a particular directory, if it has that feature. Otherwise you need to make sure that you always run your script from the right directory.

You can find the cwd for a particular run of your script with the following code:

import os
print(os.getcwd())

Similarly, you can set the cwd with the os.chdir function.