I'm using Raspberry Pi 3b, usb mic and 3.5mm audio jack as speaker. mic is hw:1,0; speaker is hw:0,0

Everything works fine except that I'm unable to get pygame.mixer.Sound.play() in a python script to work.


import time
import pygame

I get:

ALSA lib pcm_dmix.c:1052:(snd_pcm_dmix_open) unable to open slave
pygame.error: No available audio device

or MemoryError

However if I enter python2&3 environment then run the commands again, it worked fine... Appreciate the help.

  • it is possible that you are running python 2 for one of the tests and python 3 for the other test
    – jsotola
    Jul 13 '18 at 3:20
  • just entered python3 environment, and it worked too.
    – June Wang
    Jul 13 '18 at 3:23

I finally made this work.

Check your alsa.conf and .asoundrc file, only one of them needs to be configured with your audio setup.

I setup my audio in both files which caused the confusion, once I restored alsa.conf to default, the problem is gone.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.