heroku deployment, libopus not found

时间秒杀一切 提交于 2019-12-02 18:24:26

问题


I am trying to host a discord music bot in heroku, but even if it works fine in my local machine, it doesnt seem to be able to find the libopus library deployed.

Here is my requirements.txt file:

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

My 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

My 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

And the error log

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

I have searched in a lot of places and have added every package they recommended but it seems its still not enough. Hope someone can help.


回答1:


Unfortunately, Heroku can’t send the appropriate voice packets to discord, therefore you must self host or use a vps to use music. Somebody did find a loophole but idk if it was patched but chances are you won’t be able to get music https://i.stack.imgur.com/LWcF4.jpg




回答2:


I had this issue, and now have a functioning music bot with heroku. Add this buildpack https://github.com/xrisk/heroku-opus.git and then redeploy your bot and restart the dyno. This should fix the error. If that still doesn't work then try adding to the start of your code

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')


来源:https://stackoverflow.com/questions/49806427/heroku-deployment-libopus-not-found

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!