2

我有一臺Windows Server 2008 R2(64位)機器,我想在其上開發谷歌AppEngine應用程序。使用谷歌Appengine SDK PIL的麻煩

所以我從python.org安裝了Python 2.5.4(因爲Google SDK說我需要2.5和2.5.6沒有任何MSI的) 然後我安裝了PIL從http://www.pythonware.com/products/pil/我使用的版本是1.1.7 for python 2.5 我使用了這兩種的32位版本。

然後我安裝了AppEngine SDK。

你好,世界工作得很好,但我想處理的圖像,沒有工作,因爲我得到這個堆棧跟蹤和HTTP響應500:

2010-02-18 11:50:27 Running command: "['C:\\Python25\\pythonw.exe', 'C:\\Program Files 

(x86)\\Google\\google_appengine\\dev_appserver.py', '--admin_console_server=', '--port=8080', 'd:\\imgsvc']" 
WARNING 2010-02-18 10:50:29,260 datastore_file_stub.py:623] Could not read datastore data from c:\users\admini~1\appdata\local\temp\dev_appserver.datastore 
INFO  2010-02-18 10:50:29,627 dev_appserver_main.py:399] Running application imgsvc on port 8080: http://localhost:8080 
ERROR 2010-02-18 10:50:40,058 dev_appserver.py:3217] Exception encountered handling request 
Traceback (most recent call last): 
    File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\dev_appserver.py", line 3180, in _HandleRequest 
    self._Dispatch(dispatcher, self.rfile, outfile, env_dict) 
    File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\dev_appserver.py", line 3123, in _Dispatch 
    base_env_dict=env_dict) 
    File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\dev_appserver.py", line 515, in Dispatch 
    base_env_dict=base_env_dict) 
    File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\dev_appserver.py", line 2382, in Dispatch 
    self._module_dict) 
    File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\dev_appserver.py", line 2292, in ExecuteCGI 
    reset_modules = exec_script(handler_path, cgi_path, hook) 
    File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\dev_appserver.py", line 2188, in ExecuteOrImportScript 
    exec module_code in script_module.__dict__ 
    File "d:\imgsvc\imgsvc.py", line 7, in <module> 
    outputimage = images.resize(inputimage.content, 32, 32) 
    File "C:\Program Files (x86)\Google\google_appengine\google\appengine\api\images\__init__.py", line 625, in resize 
    return image.execute_transforms(output_encoding=output_encoding) 
    File "C:\Program Files (x86)\Google\google_appengine\google\appengine\api\images\__init__.py", line 513, in execute_transforms 
    response) 
    File "C:\Program Files (x86)\Google\google_appengine\google\appengine\api\apiproxy_stub_map.py", line 78, in MakeSyncCall 
    return apiproxy.MakeSyncCall(service, call, request, response) 
    File "C:\Program Files (x86)\Google\google_appengine\google\appengine\api\apiproxy_stub_map.py", line 278, in MakeSyncCall 
    rpc.CheckSuccess() 
    File "C:\Program Files (x86)\Google\google_appengine\google\appengine\api\apiproxy_rpc.py", line 149, in _WaitImpl 
    self.request, self.response) 
    File "C:\Program Files (x86)\Google\google_appengine\google\appengine\api\apiproxy_stub.py", line 80, in MakeSyncCall 
    method(request, response) 
    File "C:\Program Files (x86)\Google\google_appengine\google\appengine\api\images\images_stub.py", line 171, in _Dynamic_Transform 
    response_value = self._EncodeImage(new_image, request.output()) 
    File "C:\Program Files (x86)\Google\google_appengine\google\appengine\api\images\images_stub.py", line 193, in _EncodeImage 
    image.save(image_string, image_encoding) 
    File "C:\Python25\lib\site-packages\PIL\Image.py", line 1439, in save 
    save_handler(self, fp, filename) 
    File "C:\Python25\lib\site-packages\PIL\PngImagePlugin.py", line 564, in _save 
    import ICCProfile 
SystemError: Parent module 'PIL' not loaded 
INFO  2010-02-18 10:50:40,081 dev_appserver.py:3246] "GET/HTTP/1.1" 500 - 

的Python腳本我試圖運行:

from google.appengine.api import urlfetch 
from google.appengine.api import images 

url = "http://www.brokenwire.net/bw/images/113.png" 
inputimage = urlfetch.fetch(url) 
if inputimage.status_code == 200: 
    outputimage = images.resize(inputimage.content, 32, 32) 
    self.response.headers['Content-Type'] = "image/png" 
     self.response.out.write(outputimage) 

任何人有任何想法這裏怎麼了?

我也試過這種獨立python腳本,它工作得很好:

import Image 
im = Image.open('filename.png') 
im2 = im.resize((100,100), Image.ANTIALIAS) 
im2.show() 

看來,這讓我使用的圖像的差異:

url = "http://www.r-stone.net/blogs/ishikawa/uploaded_images/google_appengine-779483.png" 

給出問題的堆棧跟蹤,但

url = "http://www.brokenwire.net/bw/images/113.png" 

工作沒有問題。

+1

我不知道,如果它工作在GAE生產。 – Constantin 2010-02-19 13:54:27

+0

好的電話,我會試試。現在我可以正常工作,而另一個工作不正常(本地),只是很好奇,爲什麼... – thijs 2010-02-19 14:25:31

+0

檢查GAE開發服務器是否運行在安裝PIL的同一Python版本上。 – systempuntoout 2010-11-03 14:30:20

回答

2

這發生在Python找不到ICCProfile模塊時。 當使用槽GAE而不是ImportError時,輸入引發了一個SystemError,並且該函數失敗。 我所做的就是線改變... \ Python25 \ LIB \站點包\ PIL \ PngImagePlugin.py 從

except ImportError:

567:

except Exception:

0

我猜App Engine不支持PIL。目前有629人已經標記this issue要求提供Python圖像庫(PIL)(這是App Engine的第五大出演問題),我只能鼓勵你也提出這個問題。

+1

google.appengine.api.images在開發服務器上使用PIL。由於PIL並未在示例腳本中直接使用,因此這不是問題。 – geoffspear 2010-02-18 23:56:27

+1

你說得對,那不是問題。 – Emilien 2010-02-19 08:43:55

2

我在我的Windows機器上有完全相同的問題(在MacOS上它工作),所以我卸載了PIL 1.1.7並安裝了以前的1.1.6版本,現在它可以像魅力一樣工作)。

下面是該黑客來源: http://www.chris-wong.net/parent-module-pil-not-loaded/

+0

thx,這幫助我在我的Windows 7機器上。 – AZ13 2012-03-03 15:31:08