0

I have Django 1.2.1 on the server. I need to use virtually Python to install Django 1.4.1 and an adapter to PostgreSQL which I want. I am trying to set up this software on my server. So I run

virtualenv --python=python2.6 env
. env/bin/activate
pip install -r requirements.txt

Output

:~/arkisto$ virtualenv --python=python2.6 env
Running virtualenv with interpreter /usr/bin/python2.6
New python executable in env/bin/python2.6
Also creating executable in env/bin/python
Installing distribute..................................................................................................................................................................................done.
:~/arkisto$  . env/bin/activate
(env):~/arkisto$ pip install -r requirements.txt
Requirement already satisfied (use --upgrade to upgrade): psycopg2 in /usr/lib/python2.6/dist-packages (from -r requirements.txt (line 2))
Downloading/unpacking django==1.4.1 (from -r requirements.txt (line 1))
  Downloading Django-1.4.1.tar.gz (7.7Mb): 7.7Mb downloaded
  Running setup.py egg_info for package django
Installing collected packages: django
  Found existing installation: Django 1.2.3
    Not uninstalling Django at /usr/lib/pymodules/python2.6, outside environment /home/users/sa/tentti/env
  Running setup.py install for django
    changing mode of build/scripts-2.6/django-admin.py from 644 to 755
    changing mode of /home/users/sa/arkisto/env/bin/django-admin.py to 755
Successfully installed django
Cleaning up...

then seeing the version of Django in the server

(env)$ django-admin --version
1.2.3

How can you use the software installed by these commands?

4 Answers4

4

When installed via pip in virtualenv, the django admin script is normally installed under the name django-admin.py (with file extension). It is likely the system-wide django has this script installed without an extension, so you are falling back to it.

Try

$ django-admin.py --version
Theo Spears
  • 156
  • 2
3

Depending on your version of virtualenv you might need to add the --no-site-packages flag when creating the venv like this:

virtualenv --python=python2.6 --no-site-packages env

That'll tell virtualenv not to make the globally installed packages available inside your venv.

Andrew Schulman
  • 8,811
  • 21
  • 32
  • 47
user214462
  • 31
  • 2
0

Extension to user214462 answer

I run user214462's answer

virtualenv --python=python2.6 --no-site-packages env

I get

Running virtualenv with interpreter /usr/bin/python2.6
The --no-site-packages flag is deprecated; it is now the default behavior.
Overwriting env/lib/python2.6/site.py with new content
New python executable in env/bin/python2.6
Not overwriting existing python script env/bin/python (you must use env/bin/python2.6)
Overwriting env/lib/python2.6/distutils/__init__.py with new content
Installing distribute..............................................................................................................................................................................................done.
Installing pip................done.
Overwriting env/bin/activate with new content
Overwriting env/bin/activate_this.py with new content

which seems to work.

  • However, from the output `The --no-site-packages flag is deprecated; it is now the default behavior.` It seems that the `--no-site-packages` is just an no-op as it is the default. Did you try to run `django-admin.py --version` as Theo suggested? – Raymond Tau Mar 31 '14 at 00:49
0

2nd extension to user214462 answer

I am trying to combine the virtualenv command to install Django1.4.1

virtualenv --python=python2.6 --no-site-packages env python setup.py install  test/

where I do not understand the syntax. I put the folder test/ there because of the following error which I get after running it without the folder too

Running virtualenv with interpreter /usr/bin/python2.6
There must be only one argument: DEST_DIR (you gave setup.py install env test/)
Usage: virtualenv.py [OPTIONS] DEST_DIR

I think I should start the virtualenv and then put after that command in the same line the what to run in the environment.

The syntax above does not feel right because the command python is run not virtual apparently so not working.

How can you install the Django1.4.1 without making globally installed packages available inside your venv?