python / django - “不能使用ImageField因为没有安装枕头” [英] python/django - "Cannot use ImageField because Pillow is not installed"

查看:3011
本文介绍了python / django - “不能使用ImageField因为没有安装枕头”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在加入一个项目,所以我想设置环境,所以我做的是:

  pip安装-r requirements.txt 

完全安装所有要求,包括django 1.7.0,Pillow 2.4.0和其他一些。



然后我想建立数据库:

  python manage.py migrate 

和繁荣,错误,我得到以下内容:

  CommandError:系统检查确定了一些问题:

错误:
stu.chan.icon:(fields。 E210)由于没有安装枕头,因此无法使用ImageField。
提示:通过https://pypi.python.org/pypi/Pillow获取枕头或运行命令pip install pillow。
stu.chan.image:(fields.E210)由于没有安装枕头,因此无法使用ImageField。
提示:通过https://pypi.python.org/pypi/Pillow获取枕头或运行命令pip install pillow。
stu.Piec.icon:(fields.E210)由于没有安装枕头,因此无法使用ImageField。
提示:通过https://pypi.python.org/pypi/Pillow获取枕头或运行命令pip install pillow。

...像我没有安装枕头。
所以我检查了安装的包(使用技术)和枕头2.4.0 IS安装。



然后,我也试图强制重新安装: pip install --upgrade --force-reinstall Pillow == 2.4.0



但是在运行迁移时,我无法做到相同的错误。



我正在使用 python 3.4.0 django 1.7.0 在Mac OS X 10.6.7包装在$ code> virtualenv 1.11.6 with pip downgraded to pip 1.2.1 (因为一些知名但尚未完全解决的 - 不了解问题与pip和ssl )



所有上述代码都在virtualenv( bin / activate done)内。



你有什么想法吗?为什么这个问题和如何解决?



- - - - - - 编辑 - - - - - -



当我运行上面的force-reinstall命令(这么多代码被outpouted,我不能粘贴它除了)尽管它完成了成功安装枕头,代码中有一些警告:

 建立'PIL._imaging'扩展
(blabla代码)
_imaging.c:975: 13:warning:数组的数组索引超过数组的末尾(包含1个元素)[-Warray-bounds]
value = PyTuple_GET_ITEM(xy,1);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~注意:实例化:
#define PyTuple_GET_ITEM(op,i)(((PyTupleObject *)(op)) - > ob_item [i])
^
/ usr / local / include /python3.4m/tupleobject.h:27:5:注意:在这里声明的数组'ob_item'
PyObject * ob_item [1];
^
1生成警告。

(blabla code)
libImaging / Unpack.c:867:1:warning:unused function'copy3'[-Wunused-function]
copy3(UINT8 * out,const UINT8 * in,int像素)
^
1警告生成。


解决方案

我试过:




  • 使用一些说明编译Imaging-1.1.7,重新安装globaly PIL 这里,但没有工作

  • 使用该链接,但没有工作

  • 重新安装GCC4.2使用此链接,但它没有工作



我终于弄清楚,我在这个例子中描述的这个奇怪的答案这个帖子。换句话说,我正在运行一个mac,其CPU能够64位,但其内核固件设置为32位。这是一个问题,因为我正在处理的项目是为64位构建的。



正如发布,当您使用安装程序(DMG)安装python3时,如果内核设置为32相应地安装32位版本的python 3。但是,如果您只是从python的网站下载tarball源代码,请安装:

  cd Python-3.4.1 
./configure
make
sudo make install

然后,64位版本的python3应该安装。您可以通过以下操作验证:

 文件/ usr / local / bin / python3 
/ usr / local / bin / python3:Mach-O 64位可执行文件x86_64

完成后,所有问题都与PIL /枕头在virtualenv使用这64位版本的python3。即使是降级也没有必要。


I'm joining a project, so I want to set up the environnment, so what I did is :

pip install -r requirements.txt

This fully installed all requirements including django 1.7.0, Pillow 2.4.0 and some others.

Then I want to build the database :

python manage.py migrate

And boom, error, I get the following :

CommandError: System check identified some issues:

ERRORS:
stu.chan.icon: (fields.E210) Cannot use ImageField because Pillow is not installed.
    HINT: Get Pillow at https://pypi.python.org/pypi/Pillow or run command "pip install pillow".
stu.chan.image: (fields.E210) Cannot use ImageField because Pillow is not installed.
    HINT: Get Pillow at https://pypi.python.org/pypi/Pillow or run command "pip install pillow".
stu.Piec.icon: (fields.E210) Cannot use ImageField because Pillow is not installed.
    HINT: Get Pillow at https://pypi.python.org/pypi/Pillow or run command "pip install pillow".

... like I didn't install Pillow. So I checked the installed package (with this technique), and Pillow 2.4.0 IS installed.

Then, I also tried to force reinstall : pip install --upgrade --force-reinstall Pillow==2.4.0

But, nothing to do I get the same error when running migrate.

I'm using python 3.4.0 and django 1.7.0 on a mac OS X 10.6.7 wrapped in virtualenv 1.11.6 with pip downgraded to pip 1.2.1 (because of some well-known-yet-not-fully-resolved-nor-understood issue with pip and ssl).

All of the code above is within virtualenv (bin/activate done).

Do you have any ideas on why this problem and how to resolve it?

- - - - - - EDIT - - - - - -

When I run the above force-reinstall command, (so many code gets outpouted I can't paste it all but) although it finishes with "Successfully installed Pillow", there's some warnings in the code :

building 'PIL._imaging' extension
 (blabla code)
    _imaging.c:975:13: warning: array index of '1' indexes past the end of an array (that contains 1 elements) [-Warray-bounds]
        value = PyTuple_GET_ITEM(xy, 1);
                ^~~~~~~~~~~~~~~~~~~~~~~
    /usr/local/include/python3.4m/tupleobject.h:58:34: note: instantiated from:
    #define PyTuple_GET_ITEM(op, i) (((PyTupleObject *)(op))->ob_item[i])
                                     ^
    /usr/local/include/python3.4m/tupleobject.h:27:5: note: array 'ob_item' declared here
        PyObject *ob_item[1];
        ^
    1 warning generated.

(blabla code)
   libImaging/Unpack.c:867:1: warning: unused function 'copy3' [-Wunused-function]
    copy3(UINT8* out, const UINT8* in, int pixels)
    ^
    1 warning generated.

解决方案

I tried :

  • Reinstall globaly PIL by compiling "Imaging-1.1.7" using some instructions here, but didn't work
  • Reinstall Pillow and it's dependency globally using that link, but didn't work
  • Reinstall GCC4.2 using this link, but it didn't work

I finally figured out I was in the case described in the wonderfull answer to this post. In other words, I am running a mac whose CPU is capable of 64bit but whose kernel firmware is set to 32bit. Which is a problem as the project I'm working on was built for 64bit.

As explained in that post, when you install python3 using an installer (DMG) it will sniff if the kernel is set to 32 bit and install 32bit version of python 3 accordingly. But if you just download the tarball source from python's website and install it with :

cd Python-3.4.1
./configure
make
sudo make install

Then the 64bit version of python3 should be installed. Which you can verify by doing :

file /usr/local/bin/python3
/usr/local/bin/python3: Mach-O 64-bit executable x86_64

That done, all problems are gone with PIL/Pillow in the virtualenv using this 64bit version of python3. Even the pip downgrade became unnecessary.

这篇关于python / django - “不能使用ImageField因为没有安装枕头”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆