0

我正在尝试在一个非常简单的 Django 应用程序中使用 playsound 模块,并使用以下代码播放 mp3 文件:

from playsound import playsound

playsound(filename)

然而,我对 Heroku 的推动在 PyOBjC 上失败了(这显然也是需要的)。我已经安装了 playsound 和 PyObjC(没有 PyObjC,我的播放因需要 AppKit 而失败)。安装这两个模块后,该应用程序在我的本地服务器上运行良好。

在 Heroku 构建之前,这一切都很好。下面的错误片段。有没有人对我需要做些什么来让这个构建工作有任何想法?

...
remote:        Collecting pyobjc-core==6.1
remote:          Downloading pyobjc-core-6.1.tar.gz (791 kB)
remote:            ERROR: Command errored out with exit status 1:
remote:             command: /app/.heroku/python/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-l_hzqzmw/pyobjc-core/setup.py'"'"'; __file__='"'"'/tmp/pip-install-l_hzqzmw/pyobjc-core/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-install-l_hzqzmw/pyobjc-core/pip-egg-info
remote:                 cwd: /tmp/pip-install-l_hzqzmw/pyobjc-core/
remote:            Complete output (4 lines):
remote:            /app/.heroku/python/lib/python3.8/distutils/dist.py:274: UserWarning: Unknown distribution option: 'long_description_content_type'
remote:              warnings.warn(msg)
remote:            running egg_info
remote:            error: PyObjC requires macOS to build
remote:            ----------------------------------------
remote:        ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
remote:  !     Push rejected, failed to compile Python app.
remote: 
remote:  !     Push failed
remote: Verifying deploy...
remote: 
remote: !   Push rejected to db-devsite.
remote: 
To https://git.heroku.com/db-devsite.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/db-devsite.git'
4

1 回答 1

0

playsound 模块在 macOS 上使用时仅依赖于 PyObjC,对于 Linux 机器(例如 Heroku),该库依赖于“PyGObject”和 GStreamer 库。

请注意,playsound 在运行代码的机器上播放声音,这可能不是您使用 Heroku 时想要的(它会尝试在 Heroku 上播放声音的机器)。

于 2020-06-14T10:39:21.347 回答