[英]Cannot install with pip
我一直在尝试通过pip install discord.py
,但收到如下消息:
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 电源 shell 和 ZDFFF0A7FA1A596C8C1A4966 中完成了此操作
'pip' 不是内部或外部命令、可运行程序或批处理文件。
我尝试了很多在 Stack Overflow 上发现的东西,但没有任何效果。 我使用的 Python 版本是 3.7。
Pip 开始使用的时候比较混乱。 它既是命令行参数又是 python 方法。
但是,你落入了我也犯过的陷阱。 如果您想将其用作固有的命令行参数,例如> pip install [package]
,那么您需要安装 pip 应用程序。 好消息是您不需要这样做。 而是尝试将其作为 python 方法运行:
> python -m pip install [package]
由于 pip 与更高版本的python(> 3.4)捆绑在一起,因此您可以将 pip 作为 python 的方法运行。
因此,不要安装使用> pip install discord.py
,而是使用> python -m -3.7 pip install discord.py[voice]
如果您有多个版本的 python, -3.7
标签会告诉您要安装到哪个版本。 例如,如果您使用的是 3.8,则应使用-3.8
标记
Voice 用于语音支持,它只是将 PyNaCl 添加到其依赖项列表中,如果您不与 VoiceChannels 交互,它是完全可选的。
A common misconception is to not do pip install discord
just because it says v1.0.1, but in reality, discord
is just a mirror package of discord.py
on PyPi because if you look deeper, discord.py
is a dependency for discord
. 但是,仍然建议在discord
上安装discord.py
如果您使用的是 VENV(虚拟环境),请使用 package 管理器或 IDE 随附的命令行进行安装。
首先,检查您的 python 路径在哪里。 如果您已经知道这一点,那就太好了。 如果没有,那么您应该做的是在此代码中编写
import sys for p in sys.path: print(p)
第四个是您的 Python 路径。 打开该文件夹,然后 go 进入“脚本”文件夹。 Go 到 CMD 中的该路径,然后再次使用该命令。 If you don't find a Scripts folder, go to your Python path and write in your CMD python -m pip install <module>
.
如果我帮助了你,请告诉我!
如果您收到一条错误消息,指出“pip”或“python”“不被识别为内部或外部命令”或类似内容,您可能没有调整 PATH 系统变量以包含指向任一程序的可执行路径。 或者,您可能需要激活虚拟环境并使用python -m pip...
代替。
如何调整 PATH 变量
如何激活您的虚拟环境:
注意:此答案取自 discord.py 机器人 R.Danny。 您可以在此处加入官方 discord.py 服务器以使用机器人: https://discord.com/invite/r3sSKJJ
调用命令获取响应: !tag path
您可以按如下方式修复它:
方法一:重装Python,安装时一定要勾选ADD TO PATH。
方法二:找到pip的位置,一般如下C:/Program Files/Python/scripts/pip。 然后打开 CMD 并输入: setx PATH C:/Program Files/Python/scripts/pip
。
您的错误背后的原因是 PIP 安装在您的计算机上,但它没有与您的 CMD 链接。 要将其与您的 CMD 链接,它必须位于环境变量中的 PATH 内。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.