#21355 closed Bug (fixed)
Try importing _imaging from PIL namespace first.
Reported by: | Richard Xia | Owned by: | Anssi Kääriäinen |
---|---|---|---|
Component: | Utilities | Version: | 1.6 |
Severity: | Release blocker | Keywords: | pil pillow |
Cc: | preston@… | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Patch available at https://github.com/django/django/pull/1819. Fixes problem described in #20964.
On an OS X system with a Homebrew version of Python/PIL installed, the django/utils/image module encounters a hash collision error when trying to import _imaging, as described in #20964. Although that ticket was closed for not being a problem with Django, the ticket it references in the Homebrew project (https://github.com/mxcl/homebrew/issues/22135) only resulted in removing PIL from the core Homebrew libraries without actually fixing the original import issue. Everyone in the Homebrew ticket discussion agrees that pillow should be used in place of PIL, but because Django isn't officially removing support for PIL until 1.8, I believe that this problem deserves to be fixed in time for 1.6.
In my patch, I attempt to import _imaging from the PIL namespace first, which prevents the hash collision error because the _imaging module will imported using the same filesystem path as when imported through the earlier from PIL import Image
statement. If _imaging isn't available under PIL, then it attempts to import _imaging directly just as did before. This allows PIL to be properly imported in my setup (OS X 10.8, Homebrew Python/PIL) and should still be compatible with environments in which the PIL namespace isn't available.
Change History (10)
comment:1 by , 11 years ago
Cc: | added |
---|
comment:2 by , 11 years ago
comment:3 by , 11 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
comment:4 by , 11 years ago
Resolution: | wontfix |
---|---|
Status: | closed → new |
We actually have the exact same issue on a CentOS 6.4 with python-imaging (for PIL) and mod_wsgi both from CentOS. We are trying to use Django 1.6, but when using a django.forms.ImageField we are getting the error message:
ImproperlyConfigured: The '_imaging' module for the PIL could not be imported: No module named _imaging
The fix by richardxia (trying "from PIL import _imaging as PIL_imaging" first) works for us. I don't see why this shouldn't go into the official release as it seems harmless and works exactly the same as the PILImage import just a few lines above. Considering our pretty clean CentOS 6 simple setup I don't think we will be the only ones that run into this as more people migrate to Django 1.6.
Can the "wontfix" decision be re-evaluated?
comment:5 by , 11 years ago
Version: | 1.6-beta-1 → 1.6 |
---|
comment:6 by , 11 years ago
OK, so it seems this isn't Homebrew issue. I'll mark this as release blocker for 1.6. I am not sure what we should do about this. If the patch really is safe (I can't tell) then we should likely backpatch.
By marking this as release blocker I want to assure that we at least consider doing something to this before 1.6.1.
comment:7 by , 11 years ago
Severity: | Normal → Release blocker |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:8 by , 11 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
I think I will just commit the fix. The fix seems safe, and it seems there are some setups where the fix is needed.
Any objections?
comment:9 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
I'll close this as wontfix. If you must use Homebrew, then use Pillow.
ptone: I see you are in cc - if you are planning on doing something to this, just revert my wontfix.