That depends on the first line in the .py file (the "shebang line"). Commonly you'll see something like this:
In which case, the script when run as a standalone executable will run using the version of Python at /usr/bin/python2.6. Why this version of python? It might have been hard-coded into the script, but more likely it was set automatically when you installed the script. E.g. when you installed Django you either:
- Downloaded the source and ran
python setup.py - in which case the script gets installed to run with the version of python you ran setup.py using
easy_install django - in which case the script gets installed to run with the same version of python that easy_install (also a Python script) uses. (This is why you'll often see multiple versions of easy_install listed, e.g. I have easy_install-2.5, easy_install-2.6 and easy-install-2.7 available. When I just type
easy_install it uses easy_install-2.6.)
pip install django - same deal as with easy_install, pretty much.
To run the script with another version of Python you can change the shebang line (e.g. to read
#!/usr/bin/python2.7) or specify your python on the command line (e.g.
/path/to/python2.7 /path/to/django-admin.py args). Note however that scripts such as django-admin.py are just a front-end to a larger set of libraries (in this case, Django), and those libraries will have been installed by default in the library location for a specific version of Python. For example, if the first line of django-admin.py indicates that it's running under Python 2.6, the Django libraries will have been installed in a Python 2.6-specific library directory, and they won't be available by default to e.g. Python 2.7.
In other cases you'll see a shebang line like this:
In which case, the script will run with whichever version of Python you get when you just type
python at your command line. You will be able to change the version of python that scripts with this kind of shebang line have by, for example, altering your PATH environment variable so that your shell finds python in a different directory.
In either case, you should consider checking out virtualenvwrapper, an extension to virtualenv. It allows you to quickly and easily set up multiple virtual environments for Python projects, each with its own default Python version and libraries.
Update: since your question mentions OS X it's also worth mentioning that in OS X, /usr/bin/python runs a user-configurable version of Python. See the OS X python manpage for details.