Can't run python in git terminal?

前端 未结 2 1168
旧巷少年郎
旧巷少年郎 2020-12-21 14:19

I have python 3.6 installed on my Win7 system and am trying to get it working in the git bash (MINGW64), so far to no avail.

I\'ve added the install directory (NOT t

相关标签:
2条回答
  • 2020-12-21 14:30

    try using this command on your git bash: alias python='winpty python.exe If you can use Python normally and you can output and input without problems you can add that command in your .bashrc configuration file (usually in the same directory of your .git and .mintty configuration files (under your username on Windows).

    I don't know what winpty actually does but I guess it's what it's described here: https://github.com/rprichard/winpty

    0 讨论(0)
  • 2020-12-21 14:38

    why does it show PATH as having colon separators rather than semi-colon separators?

    Because bash uses : as a path separator. This means that C:/yadda/yadda in your PATH environment variable is parsed as two directories: C and /yadda/yadda. If you look closely at your echo $PATH output you will see that many entries start with /c/. The entry for your python installation is the only one which uses C:/. You should use the /c/ notation when setting PATH in .bashrc or .profile.

    Also be careful about spaces in path names and extraneous spaces before and after :. The former is definitely problematic. I am not certain about the latter since I never add spaces in this location when setting PATH.

    If I try ./python from inside that directory, it just goes to the next line when I hit enter, and allows me to keep typing because it's expecting more to the command for some reason. 

    Per the comment from @eryksun:

    You either need to run bash.exe in a normal Windows console or, if using the mintty terminal, force Python to use interactive mode via python -i. mintty hides the real console and sets StandardInput to a pipe named \\.\pipe\msys-[UNIQUE_ID]-pty0-from-master and StandardOutput to a pipe named \\.\pipe\msys-[UNIQUE_ID]-pty0-to-master. A pipe is not a character device in Windows, so isatty returns false, so Python starts in non-interactive mode unless forced otherwise via the -i option.

    0 讨论(0)
提交回复
热议问题