简体   繁体   中英

Import pyglet on python

I have downloaded the pyglet.dmg file from pyglet website and simply installed it.

The folder on which it is saved is: /Developer/pyglet

And on the pydev editor i simply state the location i want to use by:

import sys
sys.path.append('Developer/pyglet')
import pyglet

music = pyglet.resource.media('music.mp3')
music.play()

pyglet.app.run()

But for some reason i cant get this import:

python sound.py 
Traceback (most recent call last):
File "sound.py", line 3, in <module>
import pyglet
ImportError: No module named pyglet

Any idea on how to make it work?

Ok got it.

I just downloaded the source files and compiled it by myself by invoking:

sudo python setup.py install

And then simply used the sys import as described in the question.

Please add path slash.

sys.path.append('/Developer/pyglet')
                 ^

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM