1
votes

I want my Django project to use Python 2.7 instead of 2.6.8. I installed 2.7 and Django 1.5. But my project using the Python 2.6.8 which is default. How can I change it?

Update:

This is my configuration:

<Directory "/var/www/html/a/">
 SetHandler python-program
 PythonPath "['/var/www/html/'] + sys.path"
 PythonHandler django.core.handlers.modpython
 SetEnv DJANGO_SETTINGS_MODULE a.settings
 PythonDebug On
</Directory>

It seems that sys.path gets 2.6.8's paths. This is the Python path that Django sees:

['/usr/lib/python2.7/', '/var/www/html/', '/usr/lib/python2.6/site-packages/pip-1.1-py2.6.egg', '/usr/lib/python2.6/site-packages/django_transmeta-0.6.7-py2.6.egg', '/usr/lib64/python26.zip', '/usr/lib64/python2.6', '/usr/lib64/python2.6/plat-linux2', '/usr/lib64/python2.6/lib-tk', '/usr/lib64/python2.6/lib-old', '/usr/lib64/python2.6/lib-dynload', '/usr/lib64/python2.6/site-packages', '/usr/lib64/python2.6/site-packages/gtk-2.0', '/usr/lib/python2.6/site-packages', '/usr/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg-info']

1
Set path appropriately so that 2.7 comes first. You can also look at pypi.python.org/pypi/virtualenvRohan
I recommend you use a virtual environment, create a requirements file with all the frameworks, libraries, languages, etc. you want to use and their versions declaring each on one line, like so "Python==2.6.8", "Django==1.3.1" and then use the pip command to install all of the packages. Use pip like this pip install -r requirements.txt. This is one of the easiest methods.Radu Gheorghiu
I need another way without using virtualenv.Burak
deinstall your python2.6.8 then your python2.7 will become default one..doniyor
if you are using apache with mod_wsgi then add "WSGIPythonHome /path/to/python" to your httpd.confJingo

1 Answers

0
votes

Try using VirtualEnv , http://pypi.python.org/pypi/virtualenv/

This will make your task easily manageable by creating virtual environments where you can use one python version for your django installation, without breaking other applications which rely on other python versions.