0

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?

halfer
  • 19,824
  • 17
  • 99
  • 186
Hafiz
  • 4,187
  • 12
  • 58
  • 111
  • 1
    Why do you use `sudo` to start the server? – Paolo Nov 02 '12 at 20:14
  • @Guandalino Good catch, although that's not where the problem is. – millimoose Nov 02 '12 at 20:17
  • @Guandalino because otherwise it is unable to start and report some thing unable to import , so I thought it is unable to import because of somer permission related issue, does this cause problem and do it get things from global environment? – Hafiz Nov 02 '12 at 20:27

2 Answers2

4

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.

Thomas Orozco
  • 53,284
  • 11
  • 113
  • 116
  • 1
    Heck, the installer output below that command shows that it installs to `/usr/local` – millimoose Nov 02 '12 at 20:18
  • 3
    Just to add: The whole point of `virtualenv` is not to need root access and to install things relative to the venv... – miki725 Nov 02 '12 at 20:18
  • do this means that my global django settings are modified? And before starting any work with globabl settings I will need to reinstall global version or it just didn't changed anything to global as well as to localenv? – Hafiz Nov 02 '12 at 20:34
  • @Hafiz its quite possible your system Django install was modified, you might want to validate that. – Thomas Orozco Nov 02 '12 at 21:12
  • is there some tool to validate or I just need to run my existing projects to test it? – Hafiz Nov 02 '12 at 21:19
  • @Hafiz Just start up a python shell without any virtualenv activated, and check the Django version :-) – Thomas Orozco Nov 02 '12 at 21:21
1

Maybe you could try installing django with pip like this:

pip install https://www.djangoproject.com/download/1.0.4/tarball/
Michael Allan Jackson
  • 4,217
  • 3
  • 35
  • 45
Curt
  • 1,394
  • 9
  • 16