Code still runs using old version of Python
Question: I have installed python 2.7 on my CentOS server. When I go into the python
command line it tells me I'm using 2.7. When I issue a python -v command it
reports 2.7. But when I run the script I'm working on and get it to output the
version (using import sys print(sys.version)) in use it reports the old
version (2.4).

Can anyone help me get it to run the code against the new version. Thanks.


Answer: Check the first line of your script.

The [shebang](http://en.wikipedia.org/wiki/Shebang_%28Unix%29) line (first in
the script) will explain to your shell which interpreter it should use in
order to execute the contents of the file.

When I write scripts for myself I usually use:

`#!/usr/bin/env python`

Which uses which ever python interpreter is in my environment settings. Since
I use `virtualenv`, this is a local customized version of my python install by
default, but can be easily switched based on context.

