python安装django找不到set.up,python / django - “不能使用ImageField因为没有安装枕头”...

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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值