Difficulty Loading Image File in Pyglet: ResourceNotFoundException

26 views Asked by At

I'm encountering an issue while trying to load an image file in my Pyglet project. I'm receiving a ResourceNotFoundException for the file 'widgets.png'. I've double-checked the file path and ensured that the file exists in the specified location. However, the error persists.

Here's a simplified version of my code:

from pyglet.resource import Loader
from pyglet.resource import ResourceNotFoundException

# Initialize loader
loader = Loader("assets")

try:
    # Attempt to load image
    image = loader.image('widgets.png')
except ResourceNotFoundException as e:
    print(f"Error: {e}")

The error traceback indicates that the file 'widgets.png' cannot be found on the path, even though it exists. I've verified the file path and ensured that the capitalization matches exactly.

Could someone please help me identify what might be causing this issue and how to resolve it? Any insights or suggestions would be greatly appreciated. Thank you!

0

There are 0 answers