Why Behavior of Python is different on the inner and outside of IPython notebook ? "pyglet.resource.image("x.png")" is causing an error inside IPython Notebook.

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Why Behavior of Python is different on the inner and outside of IPython notebook ? "pyglet.resource.image("x.png")" is causing an error inside IPython Notebook.

buynnnmmm1
This post has NOT been accepted by the mailing list yet.
Dear, IPython-user forum,


I've used IPython notebook with Pyglet version 1.2alpha.
And I got an error with pyglet.resource.image inside IPython notbook.
But I can execute following code without the error outside IPython notebook with Pyglet version 1.2alpha.

import pyglet
pyglet.resource.image("x.png")

And I can execute these commands without the error inside IPython notbook with Pyglet version 1.1.4.

Why Behavior of Python is different on the inner and outside of IPython notebook ?



******Version 1.2alpha Pyglet ( Install with "pip install cocos2d --user --process-dependency-links"  command )
In [1]:
import pyglet

In [2]:
pyglet.resource.image("x.png")

Out[2]:
---------------------------------------------------------------------------
ResourceNotFoundException                 Traceback (most recent call last)
<ipython-input-2-fadaa8f003cf> in <module>()
----> 1 pyglet.resource.image("x.png")

/home/hogehoge/.local/lib/python2.7/site-packages/pyglet/resource.pyc in image(self, name, flip_x, flip_y, rotate, atlas)
    526         else:
    527             identity = self._cached_images[name] = self._alloc_image(name,
--> 528                 atlas=atlas)
    529
    530         if not rotate and not flip_x and not flip_y:

/home/hogehoge/.local/lib/python2.7/site-packages/pyglet/resource.pyc in _alloc_image(self, name, atlas)
    455
    456     def _alloc_image(self, name, atlas=True):
--> 457         file = self.file(name)
    458         try:
    459             img = pyglet.image.load(name, file=file)

/home/hogehoge/.local/lib/python2.7/site-packages/pyglet/resource.pyc in file(self, name, mode)
    411             return location.open(name, mode)
    412         except KeyError:
--> 413             raise ResourceNotFoundException(name)
    414
    415     def location(self, name):

ResourceNotFoundException: Resource "x.png" was not found on the path.  Ensure that the filename has the correct captialisation.

In [3]:

pyglet.resource.path

Out[3]:

['.']
 



****** with version 1.1.4 Pyglet ( Debian Package, I remove version 1.2alpha package with rm "~/.local" command )
In [1]:

import pyglet

In [2]:

pyglet.resource.image("x.png")

Out[2]:

<TextureRegion 50x38>

In [3]:

pyglet.resource.path

 

Out[3]:

['.']



With best regards
buynnnmmm1