How do I set the default python for running py files without "python" keyword i.e
$ django-admin.py manage.py startproject" in bash shell?
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:
To run the script with another version of Python you can change the shebang line (e.g. to read
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
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.
find the long version here:
for a quick shift inside running CLI session do
back to default