-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Description
It seems that the _imaging submodule in Pillow (and PIL?) does not work when Python is compiled with the --with-wide-unicode option (causing all internal string representations to be stored as 4-byte Unicode UCS4 instead of 2-byte Unicode UCS2).
Everything seems to work fine:
PIL SETUP SUMMARY
--------------------------------------------------------------------
version Pillow 2.1.0
platform darwin 3.2.5 (default, Jul 22 2013, 21:29:27)
[GCC 4.2.1 Compatible Apple Clang 3.0 (tags/Apple/clang-211.10.1)]
--------------------------------------------------------------------
*** TKINTER support not available
--- JPEG support available
--- ZLIB (PNG/ZIP) support available
--- TIFF G3/G4 (experimental) support available
--- FREETYPE2 support available
--- LITTLECMS support available
--- WEBP support available
--------------------------------------------------------------------
But importing PIL.Image does not work:
>>> from PIL import Image
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/PIL/Image.py", line 149, in <module>
if hasattr(core, 'DEFAULT_STRATEGY'):
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/PIL/Image.py", line 39, in __getattr__
raise ImportError("The _imaging C module is not installed")
ImportError: The _imaging C module is not installed
The underlying cause seems that --with-wide-unicode, the _PyUnicodeUCS2_FromString function is no longer available:
>>> from PIL import _imaging
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: dlopen(/opt/local/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/PIL/_imaging.so, 2): Symbol not found: _PyUnicodeUCS2_FromString
Referenced from: /opt/local/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/PIL/_imaging.so
Expected in: flat namespace
in /opt/local/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/PIL/_imaging.so
>>>
I suspect this problem no longer occurs with Python 3.3 and up, since that has implemented PEP 393 (Flexible string representations, as either UCS2 or UCS4).
I don't think code changes to Pillow are in order, but I certainly would appreciate a better error as to the problem. The message "The _imaging C module is not installed" was wrong and put me on the wrong foot. If this error can be improved, that would be of great help.
Thanks!