2012-03-04 54 views
6

我想產生一些PDF和Django/PIL /影像,一切都很好,直到我試圖把一些圖片到PDF:的_imaging C模塊中沒有安裝(在Windows上)

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經從PIL網站預編譯包安裝和進口_imaging是給這樣的輸出:

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. 

難道蟒蛇的x64會造成這個問題?

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

我有一個預建的包PIL的x64和它安裝在現有扎的上面,現在通過控制檯導入確實工作:

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

,但我不斷收到同樣的錯誤,而試圖生成PDF文件。

回答

13

是的,這絕對是(而且很可能是)由x64問題引起的。如果您運行Python x64,則包含本機DLL的任何模塊都需要安裝在爲x64編譯的版本中。

編輯:我無法在PIL站點找到x64的實際預編譯版本,但如果您有興趣編譯它,here是一個起點。

+0

葉OK,安裝x64和看到:>>>進口_imaging 進口_imaging#從d動態加載:\安裝\ python27 \ LIB \站點包\ PIL \ _imaging.pyd但仍得到相同的錯誤 – abolotnov 2012-03-04 20:48:28

+4

@abolotnov剛剛測試過,python x64與http://www.lfd.uci.edu/~gohlke/pythonlibs/#pil的PIL庫適合我。只要確保先卸載舊的。 – 2012-03-04 20:53:40

+0

重啓服務器,嘿嘿!謝謝! – abolotnov 2012-03-04 20:53:46

0

我在Windows上,並有一個問題「」ImportError:_imaging C模塊沒有安裝「」。

從這裏安裝Pillow解決了問題:http://www.lfd.uci.edu/~gohlke/pythonlibs/#pil。 (它是由帖子給出的,但是我找不到它回來..)

2

我有同樣的問題。我只是簡單的卸載

PIL

並安裝Pillow是替代PIL

pip install pillow

這爲我工作。

+0

謝謝!!!!!此外,這對我而言沒有卸載PIL(我試圖做到這一點時得到了點滴警告,所以我沒有) – doublefelix 2015-12-03 16:01:06

相關問題