Git Bash won't run my python files?
Adapting the PATH
should work. Just tried on my Git bash:
$ python --version
sh.exe": python: command not found
$ PATH=$PATH:/c/Python27/
$ python --version
Python 2.7.6
In particular, only provide the directory; don't specify the .exe
on the PATH
; and use slashes.
That command did not work for me, I used:
$ export PATH="$PATH:/c/Python27"
Then to make sure that git remembers the python path every time you open git type the following.
echo 'export PATH="$PATH:/c/Python27"' > .profile
Here is the SOLUTION
If you get Response:
bash: python: command not found
ORbash: conda: command not found
To the following Commands:
when you execute python
or python -V
conda
or conda --version
in your Git/Terminal window
Background: This is because you either
- Installed Python in a location on your C Drive (C:) which is not directly in your program files folder.
- Installed Python maybe on the D Drive (D:) and your computer by default searches for it on your C:
- You have been told to go to your environment variables (located if you do a search for environment variables on your machines start menu) and change the "Path" variable on your computer and this still does not fix the problem.
Solution:
At the command prompt, paste this command
export PATH="$PATH:/c/Python36"
. That will tell Windows where to find Python. (This assumes that you installed it in C:\Python36)If you installed python on your D drive, paste this command
export PATH="$PATH:/d/Python36"
.Then at the command prompt, paste
python
orpython -V
and you will see the version of Python installed and now you should not getPython 3.6.5
Assuming that it worked correctly you will want to set up git bash so that it always knows where to find python. To do that, enter the following command:
echo 'export PATH="$PATH:/d/Python36"' > .bashrc
Permanent Solution
Go to BASH RC Source File (located on C: / C Drive in “C:\Users\myname”)
Make sure your BASH RC Source File is receiving direction from your Bash Profile Source File, you can do this by making sure that your BASH RC Source File contains this line of code: source ~/.bash_profile
Go to BASH Profile Source File (located on C: / C Drive in “C:\Users\myname”)
Enter line: export PATH="$PATH:/D/PROGRAMMING/Applications/PYTHON/Python365" (assuming this is the location where Python version 3.6.5 is installed)
This should take care of the problem permanently. Now whenever you open your Git Bash Terminal Prompt and enter “
python
” or “python -V
” it should return the python version