heroku部署,找不到libopus

时间:2018-04-12 21:52:54

标签: python-3.x heroku discord

我正在尝试在heroku中托管一个不和谐的音乐机器人,但即使它在我的本地机器上工作正常,它似乎也无法找到部署的libopus库。

这是我的requirements.txt文件:

aiohttp==1.0.5
async-timeout==2.0.1
beautifulsoup4==4.6.0
certifi==2018.1.18
cffi==1.11.5
chardet==3.0.4
cycler==0.10.0
discord.py[voice]==0.16.12
matplotlib==2.1.0
multidict==4.1.0
numpy==1.13.3
opuslib==3.0.1
pycparser==2.18
PyNaCl==1.0.1
pyparsing==2.2.0
python-dateutil==2.6.1
pytz==2017.3
scikit-learn==0.19.1
scipy==0.19.1
six==1.11.0
sklearn==0.0
websockets==3.4
youtube-dl==2018.4.9

我的Aptfile

libopus0
git
libopus-dev -y
libssl-dev
libffi-dev -y
libsodium-dev -y
:repo:ppa:mc3man/xerus-media -y
build-essential -y
unzip -y
software-properties-common -y

我的buildpacks

1. https://github.com/heroku/heroku-buildpack-apt.git
2. https://github.com/heroku/heroku-buildpack-apt
3. heroku/python
4. https://github.com/jonathanong/heroku-buildpack-ffmpeg-latest.git
5. https://github.com/Crazycatz00/heroku-buildpack-libopus.git

错误日志

2018-04-12T21:48:26.872284+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/discord/client.py", line 307, in _run_event

2018-04-12T21:48:26.872287+00:00 app[worker.1]:     yield from getattr(self, event)(*args, **kwargs)

2018-04-12T21:48:26.872311+00:00 app[worker.1]:   File "main.py", line 113, in on_message

2018-04-12T21:48:26.872313+00:00 app[worker.1]:     music_service.voice_client = await client.join_voice_channel(voice_channel)

2018-04-12T21:48:26.872340+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/discord/client.py", line 3209, in join_voice_channel

2018-04-12T21:48:26.872343+00:00 app[worker.1]:     voice = VoiceClient(**kwargs)

2018-04-12T21:48:26.872369+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/discord/voice_client.py", line 230, in __init__

2018-04-12T21:48:26.872371+00:00 app[worker.1]:     self.encoder = opus.Encoder(48000, 2)

2018-04-12T21:48:26.872397+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/discord/opus.py", line 197, in __init__

2018-04-12T21:48:26.872400+00:00 app[worker.1]:     raise OpusNotLoaded()

2018-04-12T21:48:26.872450+00:00 app[worker.1]: discord.opus.OpusNotLoaded

我在很多地方搜索过并添加了他们推荐的所有软件包,但似乎还不够。希望有人可以提供帮助。

3 个答案:

答案 0 :(得分:1)

不幸的是,Heroku无法向discord发送适当的语音数据包,因此您必须自己托管或使用vps来使用音乐。有人确实找到了一个漏洞,但是如果它被修补了,那就是idk但你很有可能无法获得音乐https://i.stack.imgur.com/LWcF4.jpg

答案 1 :(得分:0)

我遇到了这个问题,现在有一个可运行的音乐机器人与heroku。添加此buildpack https://github.com/xrisk/heroku-opus.git,然后重新部署您的机器人并重新启动dyno。这应该可以修复该错误。如果仍然无法解决问题,请尝试添加到代码的开头

if not discord.opus.is_loaded():
    # the 'opus' library here is opus.dll on windows
    # or libopus.so on linux in the current directory
    # you should replace this with the location the
    # opus library is located in and with the proper filename.
    # note that on windows this DLL is automatically provided for you
    discord.opus.load_opus('opus')

答案 2 :(得分:0)

我有类似的问题。我不知道它是否对您有用,但是您可以尝试一下 (当我尝试在计算机上运行它时出现错误,但在Heroku上运行正常)。

我将此添加到了脚本中:

import ctypes
import ctypes.util
 
print("ctypes - Find opus:")
a = ctypes.util.find_library('opus')
print(a)
 
print("Discord - Load Opus:")
b = discord.opus.load_opus(a)
print(b)
 
print("Discord - Is loaded:")
c = discord.opus.is_loaded()
print(c)

请记住将其放在与音频相关的任何内容之前(最好的选择是将其粘贴在开头)。
Source