Running a python script under Linux

Steven D'Aprano steve+comp.lang.python at
Fri Dec 14 03:45:18 CET 2012

I understand this is not exactly a Python question, but it may be of 
interest to other Python programmers, so I'm asking it here instead of a 
more generic Linux group.

I have a Centos system which uses Python 2.4 as the system Python, so I 
set an alias for my personal use:

[steve at ando ~]$ which python
alias python='python2.7'

When I call "python" from the command line, it runs under 
Python 2.7 as I expected. So I give the script a hash-bang line:

#!/usr/bin/env python

and run the script directly, but instead of getting Python 2.7, it runs 
under Python 2.4 and gives me system errors.

When I run env directly, it ignores my alias:

steve at ando ~]$ /usr/bin/env python -V
Python 2.4.3

What am I doing wrong?


More information about the Python-list mailing list