#πŸ”’ Trouble loading Opus on Mac

46 messages Β· Page 1 of 1 (latest)

leaden salmon
#

Hello! I am trying to make a discord bot that will join a vc and will play music. But when I run my code it joins the vc fine, but when it goes to play the music my terminal says it couldn't load opus. Any help would be appreciated!

Here is my code: https://paste.pythondiscord.com/KJKQ

Here is what i have installed: https://paste.pythondiscord.com/PZTQ

Here is the error it keeps giving me: https://paste.pythondiscord.com/OSIA

I currently am on:
pip 25.1.1
Python 3.13.5

Any help is much appreciated I prob tried to get this fixed for at least like 4 hours last night and couldn't figure out anything... 😭

tawdry shardBOT
#

@leaden salmon

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

tired geyser
#

notice what the warning box says

In order to use PCM based AudioSources, you must have the opus library installed on your system and loaded through opus.load_opus(). Otherwise, your AudioSources must be opus encoded (e.g. using FFmpegOpusAudio) or the library will not be able to transmit audio.

#

the error is telling you that that you've not loaded opus

#

in order to load it you have to first intall it

#

do you have homebrew?

leaden salmon
tired geyser
#

is it symlinked to path?

#

im going to go eat rq brb

leaden salmon
tired geyser
#

@leaden salmon okay i'm back, just to make sure, you installed discord.py as follows right? pip install -U "discord.py[voice]"

secondly, can you show me what brew info opus gives you?

thirdly, can you put print("opus is loaded: ", discord.opus.is_loaded()) anywhere in your code, run it and show me what it prints?

leaden salmon
#

yeah

#

yes I did install pip install -U "discord.py[voice]"

#

brew info opus gave me

Audio codec
https://www.opus-codec.org/
Installed
/opt/homebrew/Cellar/opus/1.5.2 (16 files, 1MB) *
  Poured from bottle using the formulae.brew.sh API on 2024-08-12 at 10:39:25
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/o/opus.rb
License: BSD-3-Clause
==> Options
--HEAD
        Install HEAD version
==> Analytics
install: 22,890 (30 days), 66,212 (90 days), 302,705 (365 days)
install-on-request: 542 (30 days), 2,205 (90 days), 8,847 (365 days)
build-error: 0 (30 days)```
#

@tired geyser

tired geyser
#

looks okay so far

leaden salmon
#

when i put print("opus is loaded: ", discord.opus.is_loaded()) in my code it said
opus is loaded: False

#

well the whole output was

2025-06-24 13:39:29 INFO     discord.client logging in using static token
2025-06-24 13:39:29 INFO     discord.gateway Shard ID None has connected to Gateway (Session ID: 547445b49d33046e1cbd1c85c337d561).```
tired geyser
#

okay, can you cd into /opt/homebrew/lib and write ls and show me the output?

leaden salmon
#

yeah

tawdry shardBOT
#

Please react with βœ… to upload your file(s) to our paste bin, which is more accessible for some users.

leaden salmon
#

is it fine like that?

#

or do you want paste bin?

tired geyser
#

pastebin please πŸ™‚

leaden salmon
#

should it say opus somewhere in there?

tired geyser
#

can you put this discord.opus.load_opus("libopus.dylib") above your bot.run() call

leaden salmon
#

Yeah... now it just says 2025-06-24 13:45:28 INFO discord.client logging in using static token 2025-06-24 13:45:29 INFO discord.gateway Shard ID None has connected to Gateway (Session ID: 7b3af5208fa11a8c4426f74dcde3d71f).

#

id doesn't say if opus was loaded or not

tired geyser
#

where did you put the print for opus status?

leaden salmon
tired geyser
#
discord.opus.load_opus("libopus.dylib")
print("opus is loaded: ", discord.opus.is_loaded())
bot.run(token)
leaden salmon
#
2025-06-24 13:48:32 INFO     discord.client logging in using static token
2025-06-24 13:48:33 INFO     discord.gateway Shard ID None has connected to Gateway (Session ID: e29825b4084f9186c77b62eee30eddf3).```
#

i think that is a good sign!

tired geyser
#

okay, it should work now

tired geyser
leaden salmon
#

Wait it didn't play audio but i didn't get an error for that

#

but a different error occured that made the bot keep joining and leaving the vc randomly

#

ill send the error

#

Wait... i have to go to work now 😭 here is my full code if that helps https://paste.pythondiscord.com/PPBQ
i will be able to message, but i won't be able to try anything until like 9:30 p.m. CDT sorry

tired geyser
#

i'm not sure about this problem, but it does seem like the opus problem is solved now, you may wanna head to #discord-bots or the discord.gg/dpy server for help with your new problem

tawdry shardBOT
#
Python help channel closed for inactivity

This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.