DingoLingo icon indicating copy to clipboard operation
DingoLingo copied to clipboard

Issue with PyNaCl on Linux

Open Quik2007 opened this issue 2 years ago • 6 comments

Hey there, when I want to connect the bot to a voice channel, there is the following error:

Traceback (most recent call last):
  File "/home/quinten/.local/lib/python3.9/site-packages/discord/ext/commands/core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "/home/quinten/Development/SatzzeichenBot/Jazz/musicbot/commands/general.py", line 25, in _connect
    await audiocontroller.uconnect(ctx)
  File "/home/quinten/Development/SatzzeichenBot/Jazz/musicbot/audiocontroller.py", line 350, in uconnect
    await self.register_voice_channel(ctx.author.voice.channel)
  File "/home/quinten/Development/SatzzeichenBot/Jazz/musicbot/audiocontroller.py", line 47, in register_voice_channel
    await channel.connect(reconnect=True, timeout=None)
  File "/home/quinten/.local/lib/python3.9/site-packages/discord/abc.py", line 1277, in connect
    voice = cls(client, self)
  File "/home/quinten/.local/lib/python3.9/site-packages/discord/voice_client.py", line 199, 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/quinten/.local/lib/python3.9/site-packages/discord/ext/commands/bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "/home/quinten/.local/lib/python3.9/site-packages/discord/ext/commands/core.py", line 863, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "/home/quinten/.local/lib/python3.9/site-packages/discord/ext/commands/core.py", line 94, 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

I installed everything from requirements.txt and the list of linux requirements (installed with apt).

Thank you for the help!

Quik2007 avatar Apr 08 '22 16:04 Quik2007

Hi Quik, could you run python3.9 -m pip list and post the output of that here?

Nam0 avatar Apr 08 '22 18:04 Nam0

Of course!

aiohttp                       3.7.4.post0
alabaster                     0.7.8
aniso8601                     9.0.1
appdirs                       1.4.4
apturl                        0.5.2
async-timeout                 3.0.1
asyncio                       3.4.3
attrs                         21.4.0
Babel                         2.6.0
bcrypt                        3.1.7
beautifulsoup4                4.10.0
blinker                       1.4
Brlapi                        0.7.0
Brotli                        1.0.9
certifi                       2019.11.28
chardet                       3.0.4
charset-normalizer            2.0.12
chrome-gnome-shell            0.0.0
click                         8.1.2
colorama                      0.4.3
command-not-found             0.3
commonmark                    0.9.1
cryptography                  2.8
cupshelpers                   1.0
dbus-python                   1.2.16
defer                         1.0.6
discord-ui                    5.1.6
distro                        1.4.0
distro-info                   0.23ubuntu1
docutils                      0.16
duplicity                     0.8.12.0
entrypoints                   0.3
esbonio                       0.9.0
fasteners                     0.14.1
ffmpeg                        1.4
Flask                         2.1.1
Flask-JWT                     0.3.2
Flask-RESTful                 0.3.9
furo                          2022.3.4
future                        0.18.2
greenlet                      1.1.2
httplib2                      0.14.0
idna                          2.8
imagesize                     1.2.0
importlib-metadata            4.11.2
itsdangerous                  2.1.2
Jinja2                        3.1.1
keyring                       18.0.1
language-selector             0.1
launchpadlib                  1.10.13
lazr.restfulclient            0.14.2
lazr.uri                      1.0.3
lockfile                      0.12.2
louis                         3.12.0
macaroonbakery                1.3.1
Mako                          1.1.0
MarkupSafe                    2.1.1
monotonic                     1.5
multidict                     6.0.2
mutagen                       1.45.1
netifaces                     0.10.4
numerize                      0.12
oauthlib                      3.1.0
olefile                       0.46
packaging                     20.3
paramiko                      2.6.0
pexpect                       4.6.0
Pillow                        7.0.0
pip                           22.0.4
playwright                    1.20.0
protobuf                      3.6.1
py-cord                       1.7.3
pycairo                       1.16.2
pycryptodomex                 3.14.1
pycups                        1.9.73
pydantic                      1.8.2
pyee                          8.1.0
pygls                         0.11.3
Pygments                      2.11.2
PyGObject                     3.36.0
PyJWT                         1.4.2
pymacaroons                   0.13.0
pymongo                       4.1.0
PyNaCl                        1.3.0
pyparsing                     2.4.6
pyperclip                     1.8.2
pyRFC3339                     1.1
pyspellchecker                0.6.3
python-apt                    2.0.0+ubuntu0.20.4.7
python-dateutil               2.7.3
python-debian                 0.1.36ubuntu1
pytz                          2019.3
pyudev                        0.21.0
pyxdg                         0.26
PyYAML                        5.3.1
reportlab                     3.5.34
requests                      2.27.1
requests-unixsocket           0.2.0
rich                          11.2.0
roman                         2.0.0
rstcheck                      3.3.1
SecretStorage                 2.3.1
setuptools                    45.2.0
simplejson                    3.16.0
six                           1.16.0
snowballstemmer               2.2.0
soupsieve                     2.3.1
Sphinx                        4.4.0
sphinxcontrib-applehelp       1.0.2
sphinxcontrib-devhelp         1.0.2
sphinxcontrib-htmlhelp        2.0.0
sphinxcontrib-jsmath          1.0.1
sphinxcontrib-qthelp          1.0.3
sphinxcontrib-serializinghtml 1.1.5
spotipy                       2.19.0
systemd-python                234
TikTokApi                     5.0.0
typeguard                     2.13.3
typing_extensions             4.1.1
ubuntu-advantage-tools        27.7
ubuntu-drivers-common         0.0.0
ufw                           0.36
unattended-upgrades           0.1
urllib3                       1.26.9
usb-creator                   0.3.7
vboxapi                       1.0
wadllib                       1.3.3
websockets                    10.1
Werkzeug                      2.1.1
wheel                         0.34.2
xkit                          0.0.0
yarl                          1.7.2
yt-dlp                        2022.4.8
zipp                          3.7.0

Quik2007 avatar Apr 08 '22 20:04 Quik2007

Is there any chance to solve my problem?!?

Quik2007 avatar Apr 16 '22 16:04 Quik2007

What happen if you type :

  • pip install PyNaCl

RafaelSolVargas avatar Apr 17 '22 02:04 RafaelSolVargas

What happen if you type :

  • pip install PyNaCl

Pip just tells me that the requirement is already satisfied. (/usr/lib/python3/dist-packages)

Quik2007 avatar Apr 17 '22 07:04 Quik2007

I think it's some kind of bug with so many packages installed by pip, you can try to create an environment for your bot code and install only the necessary packages in it. You can read more about python virtual enviroment here: https://www.infoworld.com/article/3239675/virtualenv-and-venv-python-virtual-environments-explained.html#:~:text=To%20install%20virtualenv%2C%20just%20use,Python%203%20(see%20above).

Don't forget to activate the virtual environment, if you have any problems with it let us know. You can try running another discord bot as well to see if the problem is with the code or with your Pc, try this one: https://github.com/RafaelSolVargas/Vulkan

RafaelSolVargas avatar Apr 17 '22 13:04 RafaelSolVargas