Question

Hi I am trying to install django 1.0 , I can install latest version of django in virtualenv using pip install django but I don't need it, I just want to install django 1.0 as I have to do some simple work in that.

I have tried following things but at the end it use django1.4 that is installed on my system without any virtualenv, following is what I tried:

-laptop:/var/www/python_virtualenv$ virtualenv newenv
 New python executable in newenv/bin/python
Installing   distribute.............................................................................................................................................................................................done.

Installing pip...............done.

Then after cd to newenv, activated and installed the django 1.0 that I downloaded using following commands:

hafiz@hafiz-laptop:/var/www/python_virtualenv/newenv$ source bin/acivate
bash: bin/acivate: No such file or directory
hafiz@hafiz-laptop:/var/www/python_virtualenv/newenv$ source bin/activate
(newenv)hafiz@hafiz-laptop:/var/www/python_virtualenv/newenv$ sudo python /home/hafiz/Downloads/Django-1.0.4/setup.py install
running install
running build
running build_py
running build_scripts
running install_lib
running install_scripts
changing mode of /usr/local/bin/django-admin.py to 775
running install_data
running install_egg_info
Removing /usr/local/lib/python2.7/dist-packages/Django-1.0.4.egg-info
Writing /usr/local/lib/python2.7/dist-packages/Django-1.0.4.egg-info
(newenv)hafiz@hafiz-laptop:/var/www/python_virtualenv/newenv$ 

Then created project using:

(newenv)hafiz@hafiz-laptop:/var/www/python_virtualenv/newenv$ sudo python /usr/local/bin/django-admin.py startproject proj

then cd to proj and then started server using:

(newenv)hafiz@hafiz-laptop:/var/www/python_virtualenv/newenv/proj$ sudo python manage.py runserver 0.0.0.0:8080
  Validating models...

  0 errors found
  Django version 1.4, using settings 'proj.settings'
  Development server is running at http://0.0.0.0:8080/
  Quit the server with CONTROL-C.

but as it can be seen , django started is Django version 1.4 using settings 'proj.settings' so what I am doing wrong. I had to do something simple but having this problem, so if some once can understand the problem then please tell.

thanks

Was it helpful?

Solution

When you do sudo python /home/hafiz/Downloads/Django-1.0.4/setup.py install, the command is executed as root, which is not going to be using the virtualenv (lukily!), so this installs system-wide, not in the virtualenv, which defeats the purpose of the virtualenv (see @miki725's comment).

You can actually confirm that from looking at the output of the install (see millimoose's comment)

changing mode of /usr/local/bin/django-admin.py to 775

This is also the case for all the other commands you run. 

Conclusion:

You should drop the sudo from all your commands.

OTHER TIPS

Maybe you could try installing django with pip like this:

pip install https://www.djangoproject.com/download/1.0.4/tarball/
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top