Error for pip install Pillow on Ubuntu virtualenv

2019-01-16 12:10发布

I have an ec2 instance and had Pillow 2.0 installed in my virtualenv initially. Somehow when I tried to upgrade it to Pillow 2.5, it failed with the following message. The error is the same even after I removed Pillow completely prior to reinstall. (So now I don't have Pillow in my virtualenv at all)

$ pip install Pillow
....
....
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -Qunused-arguments -Qunused-arguments -fPIC -DHAVE_LIBJPEG -DHAVE_LIBZ -DHAVE_LIBTIFF -I/usr/include/freetype2 -I/home/andycheng/realprice/env/build/pillow/libImaging -I/home/andycheng/realprice/env/include -I/usr/include/tcl8.5 -I/usr/local/include -I/usr/include -I/usr/include/python2.7 -I/usr/include/x86_64-linux-gnu -c libImaging/RawDecode.c -o build/temp.linux-x86_64-2.7/libImaging/RawDecode.o

gcc: error: unrecognized option ‘-Qunused-arguments’

gcc: error: unrecognized option ‘-Qunused-arguments’

....
....
gcc: error: build/temp.linux-x86_64-2.7/libImaging/XbmEncode.o: No such file or directory

gcc: error: build/temp.linux-x86_64-2.7/libImaging/ZipDecode.o: No such file or directory

gcc: error: build/temp.linux-x86_64-2.7/libImaging/ZipEncode.o: No such file or directory

gcc: error: build/temp.linux-x86_64-2.7/libImaging/TiffDecode.o: No such file or directory

gcc: error: build/temp.linux-x86_64-2.7/libImaging/Incremental.o: No such file or directory

gcc: error: build/temp.linux-x86_64-2.7/libImaging/Jpeg2KDecode.o: No such file or directory

gcc: error: build/temp.linux-x86_64-2.7/libImaging/Jpeg2KEncode.o: No such file or directory

gcc: error: unrecognized option ‘-Qunused-arguments’

gcc: error: unrecognized option ‘-Qunused-arguments’

error: command 'gcc' failed with exit status 1

----------------------------------------
Cleaning up...
Command /home/andycheng/realprice/env/bin/python -c "import setuptools, tokenize;__file__='/home/andycheng/realprice/env/build/Pillow/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-U8jA_X-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/andycheng/realprice/env/include/site/python2.7 failed with error code 1 in /home/andycheng/realprice/env/build/Pillow

I don't know if this is related but there are a lot of gcc: error: build/temp.linux-x86_64-2.7/_imaging.o: No such file or directory errors in the log. And there are a lot of gcc: error: unrecognized option ‘-Qunused-arguments’ too.

I am able to install Pillow 2.5 with my root access though, but then the it will not be installed in my virtualenv.

sudo pip install Pillow  # this works but wrong directory
pip install -I Pillow==2.0  # gives the same error and would not install

Versions

PIP: 1.5.4

Linux: Ubuntu 12.04.4 LTS (all package upgraded)

Thank you

9条回答
可以哭但决不认输i
2楼-- · 2019-01-16 12:46

My case was slightly different as my ubuntu 15.04 was missing also libjpeg, so the installation failed each time. Apparently sometimes pillow can not find required library and the easiest way to fix it is to install the dev version and link it to the user libs. Edit: also works in ubuntu 16.04

sudo apt-get install python-dev
sudo apt-get install libjpeg8-dev
sudo ln -s /usr/lib/x86_64-linux-gnu/libjpeg.so /usr/lib

pip install pillow

Partial solution found here

查看更多
孤傲高冷的网名
3楼-- · 2019-01-16 12:52

Note for myself and any others, getting this to compile on Elementary OS Luna (Ubuntu 12.04) requires installation of the python headers you need for your virtualenv python version per the comments on the OP. I am using the default python version and testing 3.4 (via deadsnakes ppa) so for me this was:

sudo apt-get install python-dev
sudo apt-get install python3.4-dev

BUT! I was still getting the same error! I checked my .bashrc per the OPs answer, I didn't have any matching exports. Then it hit me, I'd been troubleshooting for a while and from an answer somewhere else I had tried setting those and hadn't restarted bash.

So don't forget to restart (or re-source I suppose) bash to make sure your exports match .bashrc!

edit: This is a bit long for a comment but not really an answer. Will modify if necessary.

查看更多
太酷不给撩
4楼-- · 2019-01-16 12:53

Ubuntu 16.04 virtualenv

pip install pillow==2.9.0
查看更多
甜甜的少女心
5楼-- · 2019-01-16 12:55

On Fedora, installing rpm-build solved it for me. Make sure you have python-devel and libjpeg-devel installed too.

查看更多
孤傲高冷的网名
6楼-- · 2019-01-16 12:55

On my CentOS machine I had to:

yum install python-devel
查看更多
Emotional °昔
7楼-- · 2019-01-16 12:57

I had the same headache too...

The solution was found after reading docs, that says:

Starting from version 3.0.0 Pillow needs libjpeg...

So try the previous one:

pip install pillow==2.9.0

(It works for python 2.6 and above)

Good Luck!

查看更多
登录 后发表回答