基本上,我在Git Bash命令行中键入python
,但返回的是一条空白线,好像命令行正在思考……
我已经进行了大量研究,但似乎无法通过在命令行中键入Python来在Git Bash上运行Python。
我看了这个问题:Python not working in the command line of git bash 并有人建议输入:
winpty c:/Python34/python.exe
输入命令行成功运行!但是,我不想每次都在命令行中输入整个命令。
基本上,我在Git Bash命令行中键入python
,但返回的是一条空白线,好像命令行正在思考……
我已经进行了大量研究,但似乎无法通过在命令行中键入Python来在Git Bash上运行Python。
我看了这个问题:Python not working in the command line of git bash 并有人建议输入:
winpty c:/Python34/python.exe
输入命令行成功运行!但是,我不想每次都在命令行中输入整个命令。
如果使用Git Bash和MinTTY,有一个需要注意的问题:Python不会进入交互模式,解决方案是强制它以这种方式启动:echo alias python=\"python -i\" >> ~/.bash_profile
我遇到了相同的问题,使用"python -i"解决了它。
~/.bashrc
或退出并重新打开终端,否则您可能无法在终端中看到该别名。 - dubesPATH=$PATH:c/Python34/
cmd.exe
和git bash中使用它,因为git bash将尊重您的环境路径。 - Kevin Burdett@Mindputty上面的答案对我来说效果最好,在.bash_profile
中添加了-i
选项:
alias py="winpty C:/Python38/python.exe -i"
alias py="winpty C:/Python38/python.exe -i"
既然您特别需要反复输入,您可能希望在您的 .bashrc 或 .bash_profile 文件中创建别名:
alias python="winpty C:/Python34/python.exe"
alias
的解决方案,这是永久性的)。 - user202729