2

Is it possible to use Jinja2 without installing it using easy_install or pip ? I dont have root access on my server but I would like to use Jinja2. I was wondering if I could do this:

import sys,os,cgi,cgitb

this_dir = os.path.abspath(os.path.dirname(__file__))
sys.path.append(os.path.join(this_dir, "Jinja2-2.7.3.tar.gz"))

from jinja2 import Template
template = Template('Hello {{ name }}!')

Edit: Sorry forgot to add but I did try it and I am getting an error : No module named jinja2 , I have confirmed that the path is correct.

2nd Edit: Lukas Graf's solution will probably work but just for information is it possible to do it without virtualenv?

Deepak
  • 341
  • 4
  • 15
  • 1
    Use a [`virtualenv`](http://virtualenv.readthedocs.org/en/latest/virtualenv.html/) - no root privileges needed. – Lukas Graf Aug 11 '14 at 20:38
  • yes but to install virtualenv i need sudo – Deepak Aug 11 '14 at 20:42
  • 3
    See [How to install virtualenv without using sudo?](http://stackoverflow.com/questions/9348869/how-to-install-virtualenv-without-using-sudo) – Lukas Graf Aug 11 '14 at 20:47
  • is it possible without using virtualenv? – Deepak Aug 11 '14 at 20:48
  • it is possible. you need to look at the path to see if it's there. if it isn't then it got added to the path for a different version of python. make sure you add it to path for the appropriate version. http://jinja.pocoo.org/docs/intro/#installation – mechanical_meat Aug 11 '14 at 20:51
  • okay so from inside my script i printed out sys.path and sure enough I get the correct path of the Jinja folder. Is a problem if the folder is inside cgi-bin (ignoring security)? – Deepak Aug 11 '14 at 20:55
  • If you *do* want to make it work without installing, you need to make sure you download the `.egg` and not the `tar.gz`. But every time you hack `sys.path`, somewhere a kitten dies. Just use `virtualenv`. – Lukas Graf Aug 11 '14 at 21:39

0 Answers0