Reputation: 4917
I am using CentOS. The default python installed is 2.4 and I also installed 2.7 in order to use Django.
How can I configure Django to use /usr/local/bin/python2.7
instead of just the default python
command?
I have to leave the default Python as 2.4 because other services such as yum
don't run with 2.7.
Or is there other solution?
Upvotes: 4
Views: 8095
Reputation: 49013
The answer is to use virtualenv
to set up a virtual environment for python2.7 and to install your stuff into that sandbox.
Here is some code to get you going:
$ sudo apt-get install python-setuptools python-dev build-essential
$ sudo easy_install -U pip
$ sudo pip install virtualenv virtualenvwrapper
$ mkdir ~/.virtualenvs
$ sudo cat >> ~/.bashrc << EOF
# virtualenvwrapper setup
export WORKON_HOME=~/.virtualenvs
export VIRTUALENVWRAPPER_VIRTUALENV_ARGS='--no-site-packages --python=python2.7'
source /usr/local/bin/virtualenvwrapper.sh
EOF
$ source ~/.bashrc
$ mkvirtualenv test
$ pip install django
I am assuming that CentOS uses sudo
like Ubuntu does. Substitute the native call if not.
Upvotes: 0
Reputation: 1345
mod_wsgi is linked with specific version of Python. You have to recompile it with Python 2.7 and make Apache load new module (by editing file like /etc/apache2/mods-enabled/wsgi.load
or /etc/apache2/modules.d/70_mod_wsgi.conf
).
http://code.google.com/p/modwsgi/wiki/InstallationIssues
Upvotes: 4
Reputation: 10936
Just run this command into your command shell: python2.7 /path/to/manage.py runserver
Then Django will run under python 2.7
Upvotes: 1