Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #51495 > unrolled thread
| Started by | Devyn Collier Johnson <devyncjohnson@gmail.com> |
|---|---|
| First post | 2013-07-29 16:56 -0400 |
| Last post | 2013-07-29 21:41 +0000 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.lang.python
Has anyone gotten Pyglet to work Devyn Collier Johnson <devyncjohnson@gmail.com> - 2013-07-29 16:56 -0400
Re: Has anyone gotten Pyglet to work Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-07-29 21:41 +0000
| From | Devyn Collier Johnson <devyncjohnson@gmail.com> |
|---|---|
| Date | 2013-07-29 16:56 -0400 |
| Subject | Has anyone gotten Pyglet to work |
| Message-ID | <mailman.5269.1375131377.3114.python-list@python.org> |
[Multipart message — attachments visible in raw view] — view raw
I tried Pyglet in a Python3 and a Python2 script, but both fail. The
error code is below and the script is attached. The 'boot.ogg' file is
Ubuntu's default bootup sound. I got my code from this link
(http://guzalexander.com/2012/08/17/playing-a-sound-with-python.html).
collier@Nacho-Laptop:~$ ./pyglet.py
Traceback (most recent call last):
File "./pyglet.py", line 2, in <module>
import pyglet
File "/home/collier/pyglet.py", line 3, in <module>
song = pyglet.media.load('./boot.ogg')
AttributeError: 'module' object has no attribute 'media'
Mahalo,
DCJ
[toc] | [next] | [standalone]
| From | Steven D'Aprano <steve+comp.lang.python@pearwood.info> |
|---|---|
| Date | 2013-07-29 21:41 +0000 |
| Message-ID | <51f6e16f$0$30000$c3e8da3$5496439d@news.astraweb.com> |
| In reply to | #51495 |
On Mon, 29 Jul 2013 16:56:06 -0400, Devyn Collier Johnson wrote:
> collier@Nacho-Laptop:~$ ./pyglet.py
Here you are running a module called pyglet, which I assume you wrote.
> Traceback (most recent call last):
> File "./pyglet.py", line 2, in <module>
> import pyglet
And here you try to import the third-party module called pyglet, except
it is shadowed by your module, and you get your own module instead.
> File "/home/collier/pyglet.py", line 3, in <module>
> song = pyglet.media.load('./boot.ogg')
> AttributeError: 'module' object has no attribute 'media'
Since your module has no attribute 'media', that error is correct.
The lesson here is, never name your own files the same as library files.
Unfortunately, that's easier said than done. I think everyone has made
the same mistake at least once in their life as a Python programmer.
--
Steven
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web