首页 文章

Bash:Python3:找不到命令(Windows,discord.py)

提问于
浏览
2

我一直在尝试配置discord API discord.py以及在我的服务器上运行Red-MusicBot . 我已经安装了Python 3.5,并添加了PATH变量(我点击了安装中的“将Python添加到PATH”选项) . 这是我的路径变量目前的样子:

C:\Users\Corey Rigney\AppData\Local\Programs\Python\Python35\Scripts\
C:\Users\Corey Rigney\AppData\Local\Programs\Python\Python35\

这些是唯一与Python相关的 . 现在,作为discord.py安装过程的一部分,它希望我在Git Bash中运行此命令:

$ git clone https://github.com/Rapptz/discord.py
$ cd discord.py
$ python3 -m pip install -U .[voice]

前两行完美,但第三行返回:

bash: python3: command not found

我还从GitHub克隆了pip作为一个尝试修复,虽然python安装网站说它包装3.5 .

我正在运行Windows 64,64位 .

这样做的总体目标是安装一个不和谐的音乐机器人,如果它能帮助我发布尝试运行时遇到的错误 .

4 回答

  • 7

    Instead of copying the executable, add a script that acts as python3 .

    带有 #!python3 shebang行的Python 3脚本将无法运行,因为Windows上不存在 python3.exe - 它可以通过 py -3 实现 .

    要解决此问题, add this script as python3 in to your PATH: it will avoke the proper Python command depending on the operating system (适用于Windows和Linux) .

    #!/usr/bin/env bash
    # Fix problem with `python3` shebang on Windows MSYS Bash
    
    if [[ "$OSTYPE" =~ ^msys ]]; then
      py -3 $*
    else
      python3
    fi
    
  • 1

    在Windows上,python可执行文件的正常名称是 python.exe (控制台程序)或 pythonw.exe (对于GUI程序) .

    python可执行文件有时在某些平台上称为 python3 ,默认情况下( python )是旧的python 2.在许多基于UNIX(包括Linux和OS X)的系统上,系统实用程序使用python 2,更改它可能有这些平台上的不良后果,因此名称"python3" .

    在Windows上你应该没问题 - 在Windows上还有其他问题,除非你尝试使用多个python版本,否则你不会得到它们 .

  • 6

    在python安装( "c:\\Installationpath\Python3.6.0" )路径中你会找到 "python.exe" ,只需在同一个地方复制粘贴并将其重命名为 "python3.exe" ,现在在命令提示符下你可以检查 python3 命令应该显示你的python安装 . 别忘了打开一个新的终端 .

  • 1

    上面的解决方案都没有为我工作,但是,当我没有写 python3 -m pip install discord.py 时,我能用Python 3.7找到成功,我写了 C:\InstallPath\python.exe -m pip install discord.py

    这可能是有效的,因为虽然命令 python3 在cmd中不可用,但python核心文件的路径仍然有效,并将参数作为 python3 命令 .

    注意:正常的 python 命令对我不起作用,因为我已经安装了2个 . Discord因某种原因需要3.5及以上?

相关问题