0

If I execute my python script on the command line for windows it runs perfectly but when I run it on bash it just keeps waiting for another line but if I try other commands such as python --version it shows: Python 2.7.10.

The command I'm running is:

python Run.py

Run.py contains:

print 'This is a test'

The bash comes with Mingw64 if that helps

1 Answers1

0

This is a known bug in MSys2, which provides the terminal used by Git Bash. You can work around it by running a Python build without ncurses support, or by using WinPTY, used as follows:

To run a Windows console program in mintty or Cygwin sshd, prepend console.exe to the command-line:

$ build/console.exe c:/Python27/python.exe
Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> 10 + 20
30
>>> exit()

The prebuilt binaries for msys are likely to work with Git Bash. (Do check whether there's a newer version if significant time has passed since this answer was posted!).

Charles Duffy
  • 235,655
  • 34
  • 305
  • 356
  • bash: build/console.exe: No such file or directory – Avid Programmer Dec 19 '15 at 21:54
  • That's an example using the WinPTY console. You need to download and install it; follow the link. (And, of course, use an invocation appropriate to the binary's actual location or status as part of your PATH). – Charles Duffy Dec 19 '15 at 21:55
  • Console crashes as soon as I click saying "msys.dll is missing". – Avid Programmer Dec 19 '15 at 22:05
  • ...an error which means exactly what it says: The binary you installed is compiled against a different msys than you have installed. – Charles Duffy Dec 19 '15 at 22:07
  • Huh? `python foo` -- which you said you were doing -- doesn't look at the shebang at all; only `./foo` does that. And on reasonable platforms (ie. not Windows), shebangs are completely awesome; they mean we don't need crap like filename extensions for executables to describe to the operating system how they should be invoked. – Charles Duffy Dec 19 '15 at 23:26