Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I use Bash on Windows, provided by MSYS.

I tried to run a Python file with a shebang of #!/usr/bin/env python, but I get this error message:

/usr/bin/env: python: No such file or directory

What can I do to make this work?

I know I can launch the Python file by suffixing it with python, but I want it to work without the suffix too.

share|improve this question

migrated from stackoverflow.com Jan 14 '12 at 23:56

This question came from our site for professional and enthusiast programmers.

4 Answers 4

Use the proper path where Python is installed instead, for example:

#!c:/Python/python.exe

If you have Unix-like path support on your system (I'm not familiar with MSYS), you can always enter the path to your python executable, i.e. the output of which python.

share|improve this answer
2  
Or you could use env, as the asker is doing. –  Ignacio Vazquez-Abrams Jan 15 '12 at 0:07
    
I can't change the shebang, it's part of a project which involves other programmers that work on Linux and Mac. –  Ram Rachum Jan 16 '12 at 11:25
    
@RamRachum What's the output of which env and which python and type python? –  Daniel Beck Jan 16 '12 at 11:33

You might be interested in a Python Launcher For Windows

share|improve this answer

What happens when you run (from the shell):

$ /usr/bin/env python

..?

If it starts an interactive python session, then python can be found. (You can also simply run: type python). If it prints "no such file or directory", then python isn't being found in your PATH. See if the following can be tweaked to fix the problem (spaces in the path/to/python will probably cause issues):

$ export PATH=$PATH:/path/to/python
$ /usr/bin/env python
share|improve this answer
up vote 0 down vote accepted

I turned out to be a mismatch between Virtualenv's activate.sh file and MSYSGIT. It was never intended to work on Windows.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.