异常值:加载失败 libasound.so.2:libasound.so.2:无法打开共享对象文件:没有这样的文件或目录 (Django/heroku)

Exception Value: Failed loading libasound.so.2: libasound.so.2: cannot open shared object file: No such file or directory (Django/heroku)

我使用 django 制作了一个用于驾驶的睡意检测器。我尝试将它部署在 heroku 上,一切似乎都运行良好,只是当我尝试打开相机时,我收到错误消息:

Exception Value:    
Failed loading libasound.so.2: libasound.so.2: cannot open shared object file: No such file or directory

其他页面都正常,你可以试试看 here (登录凭证用户名:temp 密码:Temp@123) 。只要你点击 Start Driving 它就会抛出这个异常。该应用程序在本地主机上运行良好。请帮忙!

git push heroku master 之后登录:

Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 12 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 288 bytes | 288.00 KiB/s, done.
Total 3 (delta 1), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Building on the Heroku-20 stack
remote: -----> Using buildpack: heroku/python
remote: -----> Python app detected
remote: -----> Using Python version specified in runtime.txt
remote: -----> No change in requirements detected, installing from cache
remote: -----> Using cached install of python-3.8.12
remote: -----> Installing pip 21.3.1, setuptools 57.5.0 and wheel 0.37.0
remote: -----> Installing SQLite3
remote: -----> Installing requirements with pip
remote: -----> $ python manage.py collectstatic --noinput
remote:        130 static files copied to '/tmp/build_fa3901e7/staticfiles'.
remote:
remote: -----> Discovering process types
remote:        Procfile declares types -> web
remote:
remote: -----> Compressing...
remote:        Done: 319.5M
remote: -----> Launching...
remote:  !     Warning: Your slug size (319 MB) exceeds our soft limit (300 MB) which may affect boot time.
remote:        Released v13
remote:        https://dontsleepapp.herokuapp.com/ deployed to Heroku
remote:
remote: Verifying deploy... done.
To https://git.heroku.com/dontsleepapp.git

heroku logs --tail

之后
2021-11-26T06:07:53.697167+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/django/core/handlers/base.py", line 181, in _get_response
2021-11-26T06:07:53.697168+00:00 app[web.1]: response = wrapped_callback(request, *callback_args, **callback_kwargs)
2021-11-26T06:07:53.697169+00:00 app[web.1]: File "/app/myapp/views.py", line 126, in StartDrive
2021-11-26T06:07:53.697169+00:00 app[web.1]: pygame.mixer.init()
2021-11-26T06:07:53.697169+00:00 app[web.1]: pygame.error: Failed loading libasound.so.2: libasound.so.2: cannot open shared object file: No such file or directory
2021-11-26T06:07:53.697834+00:00 app[web.1]: 10.1.4.217 - - [25/Nov/2021:22:07:53 -0800] "GET /myapp/drive/ HTTP/1.1" 500 55987 "https://dontsleepapp.herokuapp.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:94.0) Gecko/20100101 Firefox/94.0"
2021-11-26T06:07:53.701240+00:00 heroku[router]: at=info method=GET path="/myapp/drive/" host=dontsleepapp.herokuapp.com request_id=4f1d6ac0-8d16-4bd0-8ac9-381ed4758b91 fwd="73.93.42.18" dyno=web.1 connect=0ms service=66ms status=500 bytes=56254 protocol=https

你的机器缺少 libasound,安装它:sudo apt-get install libasound2