I am unable to import pygame in streamlit while deploying globally

Heyyy Can anyone help me with my streamlit deployment I am having and error while deploying the app globally when I run locally it is working but when I try to deploy globally It as not working .In specific the pygame module is not working does anyone know its alternative to start and stop the music if so please help (I even wrote it in requirement.txt)

githublink: GitHub - Va-un/Perf
this is a psuedo code might contain a small but please help me solve this pygame module not found error

Hey @varun_chindage,
Are you deploying your app on Community Cloud? Can you share a link to the deployed app so we can check out the error?


Hey @varun_chindage,
It looks like your requirements file is named requirement.txt – Community Cloud won’t recognize it unless it’s named requirements.txt

still showing the same error

You may need to reboot or redeploy your application to succesfully install and import pygame. I forked and deployed your code and I got:

pygame.error: dsp: No such audio device

as expected. Your application is running in a headless server with no audio devices.

1 Like

I reinitialized the whole app yet the same error any way to solve this error??

I don’t understand what you mean by “reinitialize”. If nothing else works, delete your application and deploy it again.

That should fix the ModuleNotFound error, but you will be greeted with another one when calling mixer.init():

Traceback (most recent call last):
  File "/home/adminuser/venv/lib/python3.9/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 541, in _run_script
    exec(code, module.__dict__)
  File "/mount/src/perf/Main.py", line 15, in <module>
pygame.error: dsp: No such audio device

Because indeed there are no audio devices in streamlit cloud.

ya i did this only but can it take permissions from my browser and use my laptops audio aur something like that so that audio works

You need a custom component to access the client computer trough the browser. I thing there is a component people are using for audio and video. I don’t remember the name but you should find it if you search the forum for related terms like pygame or pyaudio.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.