在Ubuntu virtualenv上的pip安装枕头出错

时间:2014-07-09 05:59:05

标签: ubuntu pip virtualenv pillow

我有一个ec2实例,最初在我的virtualenv中安装了Pillow 2.0。 不知何故,当我尝试将其升级到Pillow 2.5时,它失败并显示以下消息。即使我在重新安装之前完全移除了Pillow,错误也是一样的。 (所以现在我根本没有Pillow在我的演奏家中)

$ 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

我不知道这是否相关,但日志中有很多gcc: error: build/temp.linux-x86_64-2.7/_imaging.o: No such file or directory错误。而且还有很多gcc: error: unrecognized option ‘-Qunused-arguments’

我可以使用root访问权限安装Pillow 2.5,但是它不会安装在我的virtualenv中。

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

版本

PIP:1.5.4

Linux:Ubuntu 12.04.4 LTS(所有软件包升级)

谢谢

9 个答案:

答案 0 :(得分:85)

我的情况略有不同,因为我的ubuntu 15.04也缺少了libjpeg,所以安装每次都失败了。显然有时枕头找不到所需的库,最简单的修复方法是安装dev版本并将其链接到用户库。编辑:也适用于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

找到部分解决方案here

答案 1 :(得分:40)

请注意,对于我自己和其他任何人来说,在Elementary OS Luna(Ubuntu 12.04)上进行编译需要根据OP上的注释安装你的virtualenv python版本所需的python头文件。我使用默认的python版本并测试3.4(通过deadsnakes ppa)所以对我来说这是:

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

BUT!我还是得到了同样的错误!我根据OP的答案检查了我的.bashrc,我没有任何匹配的导出。然后它打了我,我已经故障排除了一段时间,并从其他地方的答案,我尝试设置那些并没有重新启动bash。

所以不要忘记重启(或重新编译我认为)bash,以确保你的出口符合.bashrc!

编辑:评论有点长,但不是真正的答案。如有必要,将进行修改。

答案 2 :(得分:23)

我也有同样的头痛......

在阅读文档之后找到了解决方案,其中说:

从版本3.0.0开始Pillow需要libjpeg ...

所以试试前一个:

pip install pillow==2.9.0

(适用于python 2.6及以上版本)

祝你好运!

答案 3 :(得分:10)

新版本3.0不起作用,我们需要安装适用于Django的2.9.0版本。在虚拟环境中执行此操作:

pip install Pillow==2.9.0

这也适用于Ubuntu,我使用的是Elementary OS。

答案 4 :(得分:8)

最后我找到了解决这个问题的答案!

事实证明我的.bashrc中有两个标记设置:

export CFLAGS=-Qunused-arguments                                    
export CPPFLAGS=-Qunused-arguments

.bashrc是从我的Macbook Pro中复制的,这两个标志是XCODE的一个解决方案。看来他们会在Linux中破解。

删除这两个标志后,pip install Pillow按预期工作。

感谢大家的帮助。

答案 5 :(得分:4)

Ubuntu 16.04 virtualenv

pip install pillow==2.9.0

答案 6 :(得分:2)

您可能需要安装python开发标题。

sudo apt-get install build-dep python-imaging

答案 7 :(得分:0)

在Fedora上,安装rpm-build为我解决了这个问题。确保您也安装了python-devellibjpeg-devel

答案 8 :(得分:0)

在我的CentOS机器上,我不得不:

yum install python-devel
相关问题