Sunny
Sunny

Reputation: 286

Installing Django and Python Suds (without admin rights)

I am trying to setup my project environment which uses the following:

The server I am running it on already has Python (2.5.2) and Django (1.1) installed but I want to use a newer version of Django and dont have administrator rights to upgrade. How do I go about installing this again?

Should I have to install Python + Django + Suds in a seperate directory? How would I replace standard python paths to this new one?

Thanks!

Upvotes: 0

Views: 1455

Answers (3)

Heartagramir
Heartagramir

Reputation: 334

A Complete Guide To setup django in other path


Installing django through pip

Well many use pip package manager for their install purpose (not my favorite).
to install django through pip you do something like:

pip install django

it will install django in a path which is not accessible by non-root users.
So you must first add the installation place for it.

pip install django --install-option="--prefix=$SOME_PLACE_WE_HAVE_ACCESS_TO" django

This $SOME_PLACE_WE_HAVE_ACCESS_TO can be /home/user/ directory.
now login to python and do the import:

import django
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named django

What are we doing wrong????

PYTHONPATH

well as long as you have not installed django in PYTHONPATH python doesn't know where to import the module!!! do this two steps:

BASH:

echo $PYTHONPATH

PYTHON:

import sys
print sys.path

well sys.path show the path of packages locations installed in python. and $PYTHONPATH is empty...

The only thing you have to do is to add the path of django egg file to PYTHONPATH for example in mine its:
/usr/local/lib/python2.7/dist-packages/Django-1.9-py2.7.egg
to add it to PYTHONPATH do this:

BASH:

export PYTHONPATH={{EGG PATH}}
which {{EGG PATH}} is the location of your django egg.
WHAT ABOUT django-admin?
well you have to run it from the place that django has set it up in somewhere it has been installed called bin for that you can add the path of that bin (Think it might be ~/bin or any_place_you_installed/bin) to $PATH...
just like PYTHONPATH we do:

export PATH=$PATH:~/bin

ATTENTION >> : after $PATH is essential!!! to know why do a: echo $PATH
ATTENTION >> ~/bin must be django bin directory so pay attention to that.

Installing django through source

OH My god That's my favorite. there is nothing difference with the thing up there just insted pip use setup.py...

for that you must have setuptools installed... (I think pip will install that itself if pip raises error for setuptools you must do the whole thing I told up there for django for setuptools too.)

after you installed setuptools you must do this:

./setup.py install --prefix=$PATH_YOU_DESIRE

the rest is the same...


REFERENCES
1 : Installing package through pip in other location.

2 : How to add a PATH To $PATH.

Upvotes: 0

forvaidya
forvaidya

Reputation: 3315

You can use virtual_env, I have used to play with another (unrelated) python framework buildbot

Upvotes: 2

Arthur Neves
Arthur Neves

Reputation: 12138

I would install it Django + Suds in a new directory! then you can grant access to everyone in this dir! then If you are running apache you just have to add this new folder to PYTHONPATH!

Just for record, I have never tried that, but it should work!

try searching about PYTHONPATH in google too, here is one link that might help: http://www.stereoplex.com/blog/understanding-imports-and-pythonpath

cheers

Upvotes: 0

Related Questions