首页 > 解决方案 > discordpy 无法使用 pip 安装

问题描述

我一直在尝试安装discordpypip install discordpy但收到以下消息:

pip : The term 'pip' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ pip install discordpy
+ ~~~
    + CategoryInfo          : ObjectNotFound: (pip:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

我在 cmd 和 windows power shell 中都这样做了,在 cmd 中,我得到的错误是:

'pip' 不是内部或外部命令、可运行程序或批处理文件。

我尝试了很多在 Stack Overflow 上发现的东西,但没有任何效果。我使用的 Python 版本是 3.7。

标签: python

解决方案


由于 pip 与更高版本的 python(>3.4) 捆绑在一起,因此您可以将 pip 作为 python 的方法运行。

因此,不要使用安装> pip install discord.py,而是使用> python -m -3.7 pip install discord.py[voice]

-3.7如果您有多个 python 版本,该标签会告诉您要安装到哪个版本。例如,如果您使用的是 3.8,则应使用-3.8标签

Voice 用于语音支持,它只是将 PyNaCl 添加到其依赖项列表中,如果您不与 VoiceChannels 交互,它是完全可选的。

一个常见的误解是不要pip install discord仅仅因为它说 v1.0.1 而做,但实际上,discord它只是discord.pyPyPi 上的镜像包,因为如果你看得更深,discord.py它是discord. 但是,仍然建议安装discord.pyoverdiscord

如果您使用的是 VENV(虚拟环境),请使用 IDE 附带的包管理器或命令行进行安装。


推荐阅读