Rapptz / discord.py

An API wrapper for Discord written in Python.
http://discordpy.rtfd.org/en/latest
MIT License
14.71k stars 3.74k forks source link

PyNaCl Issue #1916

Closed Jared-Galyan closed 5 years ago

Jared-Galyan commented 5 years ago

Okay so. I have recently put my public bot onto a hosting rather than use my computer. And they installed the correct version of discord.py rewrite with the [voice] bit at the end to install everything for voice. However when trying to connect the bot to a voice channel the console gives us this error.

Traceback (most recent call last):
File "/home/container/discord/ext/commands/core.py", line 62, in wrapped
ret = await coro(*args, **kwargs)
File "/home/container/cogs/music.py", line 247, in connect_
await channel.connect()
File "/home/container/discord/abc.py", line 975, in connect
voice = VoiceClient(state=state, timeout=timeout, channel=self)
File "/home/container/discord/voice_client.py", line 92, in __init__
raise RuntimeError("PyNaCl library needed in order to use voice")
RuntimeError: PyNaCl library needed in order to use voice
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/container/discord/ext/commands/bot.py", line 898, in invoke
await ctx.command.invoke(ctx)
File "/home/container/discord/ext/commands/core.py", line 611, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/home/container/discord/ext/commands/core.py", line 71, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: RuntimeError: PyNaCl library needed in order to use voice

Even though PyNaCl is installed

image

Harmon758 commented 5 years ago

If you're using a Linux environment, have you installed the required dependencies for voice? See https://discordpy.readthedocs.io/en/rewrite/intro.html#installing.

Jared-Galyan commented 5 years ago

I believe so yes

Jared-Galyan commented 5 years ago

Correction the host just said it's docker, alpine

Harmon758 commented 5 years ago

Correction the host just said it's docker, alpine

That is Linux.

I believe so yes

Why the ambiguity? Did you install them? Just check if you don't remember. If you haven't, then you need to do so.

Jared-Galyan commented 5 years ago

@Harmon758 As I said it's docker, alpine. The host does all the installing

Harmon758 commented 5 years ago

Alpine is a Linux distribution. I'm not sure what you mean, but just as you installed discord.py, you still need to install the dependencies required for voice, regardless of who installs it.

Gorialis commented 5 years ago

Docker does not install anything for you. Infact, the alpine image exists almost for the express purpose of not installing anything for you (it doesn't even have mount).

To get voice working on alpine, at the very least you need these packages:

I recommend doing it like this, assuming git is already installed:

# First, update the package database:
apk update
# Install our build dependencies and tag them as `voice-build-deps`:
apk add --virtual .voice-build-deps build-base libffi-dev libsodium-dev
# Install everything that isn't a build dependency, that we will need later:
apk add libffi libsodium opus-dev
# Install the library through git (this should successfully build and install PyNaCl):
pip install -U git+https://github.com/Rapptz/discord.py@rewrite#egg=discord.py[voice]
# Tell apk we no longer need the build deps:
apk del .voice-build-deps

Judging from your explanation and screenshot, your host seems to be doing part of the process for you. If you can, try to configure it to be like the above.

Your screenshot also shows PyNaCl with two dist-infos. This should never be the case on a functioning install, so it's likely that your site-packages has been broken somehow. If your host allows it, try using a fresh environment.