NameError: Global name "EventLoop" undefined - pyglet

I am trying to get python to play an audio file for me. I am writing my code in an endowed awning.

import pyglet

sound = pyglet.media.load('song.wav')
sound.play()
pyglet.app.run()

      

When I run this, I get the error: NameError: The global name "EventLoop" is undefined Also, the sound file plays the first note before program errors.

I have no idea what's going on.

ps Do I need the pylab server to be interactive for pyglet?

OS - osx 10.12.1 pyglet version 1.1.4-3

Traceback

NameError                                 Traceback (most recent call last)
/Users/name/Documents/name/Arduino Projects/python/Audio Testing.py in <module>()
      3 sound = pyglet.media.load('s.wav')
      4 sound.play()
----> 5 pyglet.app.run()

/Users/name/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/pyglet/app/__init__.pyc in run()
    262 
    263     '''
--> 264     EventLoop().run()
    265 
    266 def exit():

NameError: global name 'EventLoop' is not defined 

      

+3


source to share


1 answer


I tried to reproduce the error but was unable, although this library seems to contain several other errors as well.

I found that using the latest version of the library worked much better. My suggestion is to increase your version from 1.1.4

to 1.2.4

.



pip uninstall pyglet
pip install pyglet==1.2.4

      

+1


source







All Articles