开发者

pygame.init gives 'there is no soundcard'

Everytime I run pygame.init() I get "there is no soundcard" message. One thread in the ubuntu forums said to run pygame.init() twice and that message will disappear. The thing is, when I write a script then run the script from terminal, I still get the no sound card message.

What should I do?

Python 2.7.1+ (r271:86832, Apr 11 2011, 18:05:24) 
[GCC 4.5.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pygame,开发者_StackOverflow sys
>>> pygame.init()
there is no soundcard
(6, 0)
>>> 

Thanks!


I get the same error and just fix it on my linux-mint14 today.

First, I use apt-cache depends python-pygame to see the packages depended by python-pygame.

The result is:

依赖: python2.7
依赖: python
依赖: python
依赖: libc6
依赖: libjpeg8
依赖: libpng12-0
依赖: libportmidi0
依赖: libsdl-image1.2
依赖: libsdl-mixer1.2
依赖: libsdl-ttf2.0-0
依赖: libsdl1.2debian
依赖: libsmpeg0
依赖: libx11-6
依赖: python-numpy
依赖: ttf-freefont
  fonts-freefont-ttf
建议: timidity
冲突: <python2.3-pygame>
冲突: <python2.4-pygame>
替换: <python2.3-pygame>
替换: <python2.4-pygame>

It suggests me to install the package timidity.

Then, I use sudo apt-get install timidity to install it.

After that, there's no soundcard error when I use pygame.init()


I get the same error but the sound still works, maybe it's best to just ignore the warning.


I gave up and I am just running aplay as a subprocess started by my python script. This way seems to run faster than the pygame library itself.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜