I have a system with CentOS installed. It currently runs python2.6, but python2.7 is also installed.
I want to run django 1.7, which is also currently installed. If I run django outside of a virtualenv, it is using python2.6 by default. I didn't install it myself.
What I assume is a way to get around this is to create a virtualenv. Which I've done, and used --python=python2.7. But when I create the virtualenv, and install a new django 1.7 in it (with pip), it still uses python2.6 instead of 2.7.
Since I'm doing this all through ssh, I'd like an easy way around it (rather than compiling from source, etc). Is there a way to specify that django uses python2.7 when I install it with pip in the virtualenv? Or what is the right way to correct this issue?
Here is what I have done:
ssh into account.
$ mkdir project; cd project
$ virtualenv env --python=python2.7
$ cd env
$ source bin/activate
$ sudo easy_install-2.7 pip
$ pip install django==1.7
Then I go into my python interpreter. The interpreter is running 2.7 and if I import django, it all works okay. But as soon as I run
django-admin.py startproject project_name
it is back to using 2.6.
Invoke django-admin.py like this
python django-admin.py
, in your activate virtualenv. Alternatively you can do/path/to/virtualenv/bin/python django-admin.py
. The best solution is probably adding a shebang to django-admin.py that looks like#!/usr/bin/env python
which should use the python interpreter of your active virtualenv. See https://stackoverflow.com/a/2255961/639054