The _imaging C module is not installed (on windows)
Question:
I’m trying to generate some pdf with django/PIL/Imaging and everything is good until I attempt to put some images into the pdf:
Exception Type: ImportError
Exception Value:
The _imaging C module is not installed
Exception Location: D:installpython27libsite-packagesPILImage.py in __getattr__, line 37
Python Executable: D:installpython27python.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 via pre-compiled bundle from PIL website and importing _imaging was giving 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.
Could python x64 be causing this issue?
Python 2.7.1 (r271:86832, Feb 7 2011, 11:33:02) [MSC v.1500 64 bit (AMD64)] on win32
I got a pre-built package for x64 of PIL and installed it on top of existing bundle, now import via console does work:
>>> import _imaging
import _imaging # dynamically loaded from D:installpython27libsite-packagesPIL_imaging.pyd
but I keep getting the same error whilst trying to generate the pdf file.
Answers:
Yes, this could definitely be (and most likely is) caused by an x64 issue. If you’re running Python x64, any module that includes a native DLL needs to be installed in a version compiled for x64 too.
Edit: I cannot find an actual precompiled version for x64 at the PIL site, but here is a starting point if you’re interested in compiling it yourself.
I am on Windows, and had a problem “”ImportError: The _imaging C module is not installed””.
The problem solved by installing Pillow from here: http://www.lfd.uci.edu/~gohlke/pythonlibs/#pil. (it’s given by a post however I can’t locate it back..)
I had the same problem. I just simply uninstalled
PIL
and installed Pillow
which is replacement for PIL
pip install pillow
This worked for me.
This is an old question… but it seems the issue can still arise.
In my case (Windows 11/x64), I was able to solve the issue by using the pip version of pillow rather than the conda one:
pip install --force pillow
Not sure this is the cleanest way but at least it works!
I was having the same problem on windows. I simply uninstalled pillow and then installed it again, it worked for me.
pip uninstall pillow
pip install pillow
PS: I did this on anaconda’s terminal and in the base environment.
I’m trying to generate some pdf with django/PIL/Imaging and everything is good until I attempt to put some images into the pdf:
Exception Type: ImportError
Exception Value:
The _imaging C module is not installed
Exception Location: D:installpython27libsite-packagesPILImage.py in __getattr__, line 37
Python Executable: D:installpython27python.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 via pre-compiled bundle from PIL website and importing _imaging was giving 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.
Could python x64 be causing this issue?
Python 2.7.1 (r271:86832, Feb 7 2011, 11:33:02) [MSC v.1500 64 bit (AMD64)] on win32
I got a pre-built package for x64 of PIL and installed it on top of existing bundle, now import via console does work:
>>> import _imaging
import _imaging # dynamically loaded from D:installpython27libsite-packagesPIL_imaging.pyd
but I keep getting the same error whilst trying to generate the pdf file.
Yes, this could definitely be (and most likely is) caused by an x64 issue. If you’re running Python x64, any module that includes a native DLL needs to be installed in a version compiled for x64 too.
Edit: I cannot find an actual precompiled version for x64 at the PIL site, but here is a starting point if you’re interested in compiling it yourself.
I am on Windows, and had a problem “”ImportError: The _imaging C module is not installed””.
The problem solved by installing Pillow from here: http://www.lfd.uci.edu/~gohlke/pythonlibs/#pil. (it’s given by a post however I can’t locate it back..)
I had the same problem. I just simply uninstalled
PIL
and installed Pillow
which is replacement for PIL
pip install pillow
This worked for me.
This is an old question… but it seems the issue can still arise.
In my case (Windows 11/x64), I was able to solve the issue by using the pip version of pillow rather than the conda one:
pip install --force pillow
Not sure this is the cleanest way but at least it works!
I was having the same problem on windows. I simply uninstalled pillow and then installed it again, it worked for me.
pip uninstall pillow
pip install pillow
PS: I did this on anaconda’s terminal and in the base environment.