1

I am trying to upload and resize an image using PIL on Django 1.4.1.

I have tried this: https://stackoverflow.com/a/10109941/356875

but nothing changed.

I use virtualenv and when I do pip install -I PIL I get this error:

running install_lib

creating /usr/lib/python2.7/site-packages

error: could not create '/usr/lib/python2.7/site-packages': Permission denied

so I have to sudo pip install -I PIL which works and gives me this:

   PIL 1.1.7 SETUP SUMMARY
    --------------------------------------------------------------------
    version       1.1.7
    platform      linux2 2.7.3 (default, Sep 26 2012, 21:51:14)
                  [GCC 4.7.2]
    --------------------------------------------------------------------
    *** TKINTER support not available
    --- JPEG support available
    --- ZLIB (PNG/ZIP) support available
    *** FREETYPE2 support not available
    *** LITTLECMS support not available
    --------------------------------------------------------------------
    To add a missing option, make sure you have the required
    library, and set the corresponding ROOT variable in the
    setup.py script.

    To check the build, run the selftest.py script.
    changing mode of build/scripts-2.7/pildriver.py from 644 to 755
    changing mode of build/scripts-2.7/pilprint.py from 644 to 755
    changing mode of build/scripts-2.7/pilfile.py from 644 to 755
    changing mode of build/scripts-2.7/pilconvert.py from 644 to 755
    changing mode of build/scripts-2.7/pilfont.py from 644 to 755

    changing mode of /usr/local/bin/pildriver.py to 755
    changing mode of /usr/local/bin/pilprint.py to 755
    changing mode of /usr/local/bin/pilfile.py to 755
    changing mode of /usr/local/bin/pilconvert.py to 755
    changing mode of /usr/local/bin/pilfont.py to 755
Successfully installed PIL
Cleaning up...

However when I try to save a model I get this error:

IOError at /admin/main/pagecategory/21/

decoder jpeg not available

Request Method:     POST
Request URL:    http://localhost:8000/admin/main/pagecategory/21/
Django Version:     1.4.1
Exception Type:     IOError
Exception Value:    

decoder jpeg not available

Exception Location:     /home/chris/.virtualenvs/holistic/lib/python2.7/site-packages/PIL/Image.py in _getdecoder, line 385
Python Executable:  /home/chris/.virtualenvs/holistic/bin/python
Python Version:     2.7.3
Python Path:    

['/home/chris/Dropbox/workspace/holistic',
 '/home/chris/.virtualenvs/holistic/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg',
 '/home/chris/.virtualenvs/holistic/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg',
 '/home/chris/.virtualenvs/holistic/lib/python2.7',
 '/home/chris/.virtualenvs/holistic/lib/python2.7/plat-linux2',
 '/home/chris/.virtualenvs/holistic/lib/python2.7/lib-tk',
 '/home/chris/.virtualenvs/holistic/lib/python2.7/lib-old',
 '/usr/lib/python2.7/lib-dynload',
 '/usr/lib/python2.7',
 '/usr/lib/python2.7/plat-linux2',
 '/usr/lib/python2.7/lib-tk',
 '/home/chris/.virtualenvs/holistic/lib/python2.7/site-packages',
 '/home/chris/.virtualenvs/holistic/lib/python2.7/site-packages/PIL',
 '/usr/local/lib/python2.7/site-packages',
 '/usr/local/lib/python2.7/dist-packages',
 '/usr/local/lib/python2.7/dist-packages/PIL']

Server time:    Fri, 4 Jan 2013 12:35:58 +0200

What am I doing wrong?

(PS: exact same configuration works fine on my remote hosting linux server)

EDIT: I dpasted another detailed output Thank you. http://dpaste.com/867770/

Community
  • 1
  • 1
xpanta
  • 8,124
  • 15
  • 60
  • 104
  • I think you need to install using `-E ` option. – Rohan Jan 04 '13 at 12:44
  • I find it weird that `pip` tries to install in `/usr/lib/python2.7/site-packages` when it's running under `virtualenv`. Shouldn't it be installing in `/home/chris/.virtualenvs/holistic/lib/pyhon2.7/site-packages` instead? Have you used the correct `pip` to install the `PIL`? See also the [documentation](http://www.pip-installer.org/en/latest/other-tools.html#using-pip-with-virtualenv). –  Jan 04 '13 at 12:53
  • @Rohan this is what I get: `pip install -E holistic PIL Usage: pip install [OPTIONS] PACKAGE_NAMES... no such option: -E` @Evert I am always using the same pip (after I had done a `workon ` command. Everything is installed in my virtual environment. PIL is the only problem up to now) – xpanta Jan 04 '13 at 14:07
  • I have the same issue with Pillow (the PIL drop in). Says JPEG is ok on configure, but then falls over when I try and load a JPEG. – joedborg Jul 10 '13 at 11:03

1 Answers1

0

Probably there is some problem with your activate/workon script. Try passing your virtualenv's pip absolute path, like:

$ /tmp/myenv/bin/pip install -I PIL

In order to check if PIL is installed in your virtualenv, do:

$ /tmp/myenv/bin/python -c 'import PIL'

If it gives you no error, it is correctly installed.

Maybe your problem is the same as this: System PIP instead of virtualenv PIP by default?

Community
  • 1
  • 1
Hugo Lopes Tavares
  • 28,528
  • 5
  • 47
  • 45