Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Resource Not Found Exception in pyglet

Tags:

pyglet

I'm using Python 2.6.6 and pyglet 1.1.4. In my "Erosion" folder, I have "Erosion.py" and a folder named "Images." Inside images, there are .png images. One image is named "Guard.png."

In "Erosion.py" there is a segment that goes like so:

pyglet.resource.path = ['Images']
pyglet.resource.reindex()
self.image = pyglet.resource.image('%s%s' % (character, '.png'))

When I run this, I am given

File "C:\Python26\lib\site-packages\pyglet\resource.py", line 394, in file raise ResourceNotFoundException(name)
ResourceNotFoundException: Resource "Guard.png" was not found on the path.  Ensure that the filename has the correct captialisation.

I have tried changing the path to ['./Images'] and ['../Images']. I've also tried removing the path and the reindex call and putting Erosion.py and Guard.png in the same folder.

like image 340
Jack Avatar asked Jun 30 '11 21:06

Jack


2 Answers

This is what i do to be able to load resources:

pyglet.resource.path = ['C:\\Users\\myname\\Downloads\\temp']
pyglet.resource.reindex()

pic = pyglet.resource.image('1.jpg')

texture = pic.get_texture()
gl.glTexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MAG_FILTER, gl.GL_NEAREST)

texture.width = 960
texture.height = 720

texture.blit(0, 0, 0)
like image 86
Torxed Avatar answered Jan 19 '23 10:01

Torxed


try this

pyglet.image.load('path/to/image.png')
like image 28
Jim Syyap Avatar answered Jan 19 '23 10:01

Jim Syyap