can't install the pillow library on my first attempt to add an ImageField to my model

1,067 views
Skip to first unread message

aseds

unread,
Jan 21, 2015, 8:44:01 AM1/21/15
to django...@googlegroups.com
hi,
 this is the first time i tried and added an ImageField to my model. then i did makemigrations
./manage.py makemigrations

but it said that i should do:
pip install pillow
(the django documentation says it's a required library too...)

doing so, it gave me some errors:
~/W/d/mysitepip install pillow                           
Downloading/unpacking pillow
  Downloading Pillow-2.7.0.tar.gz (7.4MB): 7.4MB downloaded
  Running setup.py (path:/tmp/pip_build_aseds/pillow/setup.py) egg_info
 for package pillow
    Single threaded build, not installing mp_compile: 1 processes
    
Installing collected packages: pillow
  Running setup.py install for pillow
    Single threaded build, not installing mp_compile: 1 processes
    
    building 'PIL._imaging' extension
    x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwr
apv -O2 -Wall -Wstrict-prototypes -fPIC -I/tmp/pip_build_aseds/pillow/l
ibImaging -I/usr/include -I/usr/local/include -I/usr/include/python2.7 
-I/usr/include/x86_64-linux-gnu -c _imaging.c -o build/temp.linux-x86_6
4-2.7/_imaging.o
   _imaging.c:76:20: fatal error: Python.h: No such file or directory
     #include "Python.h"
                        ^
    compilation terminated.
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
    Complete output from command /usr/bin/python -c "import setuptools,
 tokenize;__file__='/tmp/pip_build_aseds/pillow/setup.py';exec(compile(
getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'),
 __file__, 'exec'))" install --record /tmp/pip-GeeYvn-record/install-re
cord.txt --single-version-externally-managed --compile:
    Single threaded build, not installing mp_compile: 1 processes
 
running install

running build
 
running build_py
 
creating build
 
creating build/lib.linux-x86_64-2.7
 
creating build/lib.linux-x86_64-2.7/PIL
 
copying PIL/ImageTransform.py -> build/lib.linux-x86_64-2.7/PIL
:
:
:
i thought probably not all of it is important...
:
:
:
creating build/temp.linux-x86_64-2.7/libImaging
 
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv 
-O2 -Wall -Wstrict-prototypes -fPIC -I/tmp/pip_build_aseds/pillow/libIm
aging -I/usr/include -I/usr/local/include -I/usr/include/python2.7 -I/u
sr/include/x86_64-linux-gnu -c _imaging.c -o build/temp.linux-x86_64-2.
7/_imaging.o
 
_imaging.c:76:20: fatal error: Python.h: No such file or directory
 
 #include "Python.h"
 
                    ^
 
compilation terminated.
 
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
 
----------------------------------------
Cleaning up...
Command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/
pip_build_aseds/pillow/setup.py';exec(compile(getattr(tokenize, 'open',
 open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" inst
all --record /tmp/pip-GeeYvn-record/install-record.txt --single-version
-externally-managed --compile failed with error code 1 in /tmp/pip_buil
d_aseds/pillow
Storing debug log for failure in /home/aseds/.pip/pip.log

i don't know exactly what is wrong cause i'm still a newbie with python.                                                                                                                                                                     and at the end i should thank you for spending time helping me! thank you so much!                                                                                                                                                 

Vijay Khemlani

unread,
Jan 21, 2015, 9:13:23 AM1/21/15
to django...@googlegroups.com
You need to install the development python package for your distro

For example, in Ubuntu

sudo apt-get install python-dev

in Fedora

sudo yum install python-devel

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/b5db0e6e-0d16-45bb-aec3-ac6e63bdd957%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

aseds

unread,
Jan 21, 2015, 11:53:56 AM1/21/15
to django...@googlegroups.com
thank you Vijay, the error has changed. now i've got
error: could not create '/usr/local/lib/python2.7/dist-packages/PIL': Permission denied
 
----------------------------------------
Cleaning up...
Command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip_build_aseds/pillow/setup.py';exec(compile(getattr(tokenize, 'op
en', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-p5GAWn-record/install-record.txt --single
-version-externally-managed --compile failed with error code 1 in /tmp/pip_build_aseds/pillow
Storing debug log for failure in /home/aseds/.pip/pip.log

so, should i change the Permission for "dist-packages"?? is it safe to run the below command?
chmod 777 dist-packages
or what should i do?

Vijay Khemlani

unread,
Jan 21, 2015, 11:59:30 AM1/21/15
to django...@googlegroups.com
Since you are using the system-wide python installation you need to run pip as superuser

sudo pip install pillow

You could also create a virtualenv instead of installing packages system-wide, which is the recommended way of creating development environments.

aseds

unread,
Jan 21, 2015, 12:08:34 PM1/21/15
to django...@googlegroups.com
thanks again...
Reply all
Reply to author
Forward
0 new messages