_Imaging C module not installed (on windows)

I am trying to create some pdf file with django / PIL / Imaging, and all is fine until I try to put some images in pdf:

Exception Type: ImportError Exception Value: The _imaging C module is not installed Exception Location: D:\install\python27\lib\site-packages\PIL\Image.py in __getattr__, line 37 Python Executable: D:\install\python27\python.exe Python Version: 2.7.1 Python Path: ['D:\\~Sasha\\Portman', 'D:\\install\\python27\\lib\\site-packages\\setuptools-0.6c11-py2.7.egg', 'D:\\install\\python27\\lib\\site-packages\\pisa-3.0.33-py2.7.egg', 'D:\\install\\python27\\lib\\site-packages\\html5lib-0.95-py2.7.egg', 'D:\\install\\python27\\lib\\site-packages\\pypdf-1.13-py2.7.egg', 'D:\\install\\PyCharm 2.0.2\\helpers', 'D:\\~Sasha\\Portman', 'D:\\~Sasha', 'C:\\Windows\\system32\\python27.zip', 'D:\\install\\python27\\DLLs', 'D:\\install\\python27\\lib', 'D:\\install\\python27\\lib\\plat-win', 'D:\\install\\python27\\lib\\lib-tk', 'D:\\install\\python27', 'D:\\install\\python27\\lib\\site-packages', 'D:\\install\\python27\\lib\\site-packages\\PIL'] 

PIL was installed through a precompiled package from the PIL website, and the _imaging import gave this output:

 Python 2.7.1 (r271:86832, Feb 7 2011, 11:33:02) [MSC v.1500 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import _imaging Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: DLL load failed: %1 is not a valid Win32 application. 

Can python x64 cause this problem?

 Python 2.7.1 (r271:86832, Feb 7 2011, 11:33:02) [MSC v.1500 64 bit (AMD64)] on win32 

I got a ready-made package for x64 PIL and installed it on top of an existing package, now import through the console works:

 >>> import _imaging import _imaging # dynamically loaded from D:\install\python27\lib\site-packages\PIL\_imaging.pyd 

but I keep getting the same error trying to create a pdf file.

+6
source share
3 answers

Yes, it can definitely be (and most likely) caused by the x64 problem. If you are using Python x64, any module containing an embedded DLL must be installed in the version compiled for x64 too.

Edit: I cannot find a real precompiled version for x64 on the PIL site, but here is a starting point if you are interested in compiling it.

+13
source

I had the same problem. I just deleted

PIL

and installed Pillow , which replaces PIL

pip install pillow

It worked for me.

+2
source

I am on Windows and have the problem "ImportError: _imaging C module not installed". "

The problem is solved by installing Pillow from here: http://www.lfd.uci.edu/~gohlke/pythonlibs/#pil . (It is given by the message, however I cannot find it back.)

0
source

Source: https://habr.com/ru/post/909957/


All Articles