Why isn't git bash transforming the path to *nix notation for my python installation?

旧街凉风 提交于 2019-12-22 01:06:58

问题


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:

  1. *nix uses : as a path separator.

  2. Therefore C:/Users/Someone would be seen as two separate paths.

  3. *nix uses /c/users/someone notation instead.

  4. 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--

  5. --except Python, which still has the C:/ notation, and is therefore not accessible from the terminal since it can't find it.

  6. 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.


回答1:


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!