I’ve been trying to configure the discord API discord.py and for the purpose of running the Red-MusicBot on my server. I’ve installed Python 3.5, and added the PATH variables (I clicked the “add Python to PATH” option in install). Here’s what my path variables currently look like:
C:UsersCorey RigneyAppDataLocalProgramsPythonPython35Scripts
C:UsersCorey RigneyAppDataLocalProgramsPythonPython35
Those are the only ones related to Python. Now, as part of discord.py’s install process, it wants me to run this command in Git Bash:
$ git clone https://github.com/Rapptz/discord.py
$ cd discord.py
$ python3 -m pip install -U .[voice]
The first two lines work perfectly, but the third line returns:
bash: python3: command not found
I also cloned pip from GitHub as an attempted fix, although the python install site says it comes packaged with 3.5.
I’m running windows 10, 64-bit.
The overall goal of this is to install a discord music bot, if it would help I can post the errors I get when trying to run that.
6 Answers
On Windows the normal name for the python executable is python.exe
(console program) or pythonw.exe
(for GUI programs).
The python executable is sometimes called python3
on some platforms, where the default (python
) is the old python 2. On many UNIX-based (inc. Linux and OS X) systems, python 2 is used by system utilities, changing it could have bad consequences on those platforms, hence the name “python3”.
On Windows you should be fine – there are other issues on Windows but you won’t get those unless you try to use more than one python version.
In the python installed("c:\InstallationpathPython3.6.0"
) path you will find "python.exe"
, just copy paste in the same place and rename it as "python3.exe"
, now in the command prompt you can check python3
command should display your python installation. Don’t forget to open a new terminal.
In windows using git bash, python3 didn’t worked for me:
$ python --version
Python 2.7.15
but if I use py
$ py --version
Python 3.8.1
doesn’t know why, but It worked
Instead of copying the executable, add a script that acts as python3
.
A Python 3 script with #!python3
shebang line will fail to run, because python3.exe
is not exists on Windows – it can be achieved by py -3
.
To solve the problem, add this script as python3
in to your PATH
: it will avoke the proper Python command depending on the operating system (works on Windows and Linux as well).
#!/usr/bin/env bash
# Fix problem with `python3` shebang on Windows MSYS Bash
if [[ "$OSTYPE" =~ ^msys ]]; then
py -3 $*
else
python3
fi
None of the solutions above worked for me, however, I was able to find success with Python 3.7 when instead of writing python3 -m pip install discord.py
, I wrote C:InstallPathpython.exe -m pip install discord.py
This probably worked because while the command python3
was not available in cmd, the path to the python core file worked and took the arguments as the python3
command would.
NOTE: The normal python
command was not working for me, as I already have 2 installed. Discord for some reason requires 3.5 and above?
On Windows 10 you might find that py
works where python
or python3
doesn’t.