已安装但仍在运行时错误:需要PyNaCl库才能使用语音

2024-05-16 12:54:16 发布

您现在位置:Python中文网/ 问答频道 /正文

@client.command()
async def join(ctx):
    if ctx.message.author.voice:
        channel = ctx.author.voice.channel
        await channel.connect()

为了练习,我一直在开发一个discord机器人,我一直在努力让它加入一个语音频道。我已经安装了PyNaCl,我已经用pip在1.3.0和1.4.0之间进行了交换,看看它是否会有什么不同,什么都没有。我确保安装LibNadium的目的是为了解决这个问题,但每当我试图让机器人加入语音频道时,仍然会遇到同样的错误

我愿意尝试任何其他故障排除方法和修复,但我已经搜索了stackoverflow,到目前为止没有结果

import discord
from discord.ext import commands
import random
import youtube_dl
from discord import channel


try:
    import nacl.secret
    has_nacl = True
except ImportError:
    has_nacl = False

这些都是我工作的导入,我尝试只使用“import.nacl”,也没有结果

Traceback (most recent call last):
  File "C:\Users\Fernando\AppData\Roaming\Python\Python37\site-packages\discord\ext\commands\bot.py", line 903, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\Fernando\AppData\Roaming\Python\Python37\site-packages\discord\ext\commands\core.py", line 859, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "C:\Users\Fernando\AppData\Roaming\Python\Python37\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

谢谢你抽出时间


Tags: infromimportchannelawaitusersappdataext