Working on Windows 7, I've installed git with the git bash and then installed python and am having trouble running it from the command line. Here's what I've learned so far:
*nix uses
:
as a path separator.Therefore
C:/Users/Someone
would be seen as two separate paths.*nix uses
/c/users/someone
notation instead.When I run
echo $PATH
from git bash, every path there (including Node, which I only just installed now, after everything else) is using the correct/c/
notation----except Python, which still has the
C:/
notation, and is therefore not accessible from the terminal since it can't find it.When I go to Environment Variables and check the path from the os's perspective, they are of course all in
C:/
notation.
How, where, and/or why is git bash converting all of them to its own notation except python? How can I fix this?
Here is PATH
as seen in Environment Variables in Windows Advanced Settings:
C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\; C:\Users\Aerovistae\AppData\Local\Programs\Python\Python36-32;C:\Users\Aerovistae\AppData\Roaming\npm
Here it is as seen from git bash:
/c/Users/Aerovistae/bin:/mingw64/bin:/usr/local/bin:/usr/bin:/bin:/mingw64/bin:/usr/bin:/c/Users/Aerovistae/bin:/c/Windows/system32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0:/c/Program Files/Intel/WiFi/bin:/c/Program Files/Common Files/Intel/WirelessCommon:/cmd:/c/Program Files (x86)/Skype/Phone:/c/Program Files (x86)/Windows Kits/8.1/Windows Performance Toolkit:/c/Program Files/nodejs:/c/Program Files/Intel/WiFi/bin:/c/Program Files/Common Files/Intel/WirelessCommon: C:/Users/Aerovistae/AppData/Local/Programs/Python/Python36-32:/c/Users/Aerovistae/AppData/Roaming/npm:/usr/bin/vendor_perl:/usr/bin/core_perl
You can see near the end that Python is the only one with the wrong notation.
Open a new CMD, and set the minimal PATH you need:
set PATH=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem
set GIT_HOME=C:\Path\to\Git
set PATH=%GIT_HOME%;%GIT_HOME%\bin;%GIT_HOME%\usr\bin;%PATH%
SET PATH=C:\Users\Aerovistae\AppData\Local\Programs\Python\Python36-32;%PATH%
(Make sure python.exe
is indeed in C:\Users\Aerovistae\AppData\Local\Programs\Python\Python36-32
)
Then, type bash
, and see if python.exe
works.
You can also add your previous paths, to identify the one causing trouble.
In the OP's case, the stray leading space for the Python path was the troublemaker.
来源:https://stackoverflow.com/questions/41527492/why-isnt-git-bash-transforming-the-path-to-nix-notation-for-my-python-installa