2010-07-27 60 views
0

我想從python程序使用py2exe創建一個.exe,但是當我運行.exe我得到一個日誌文件與在PIL ImageStat.Stat py2exe拋出異常:參數2必須是ImagingCore,而不是ImagingCore

Exception in thread Thread-1: 
Traceback (most recent call last): 
    File "threading.pyc", line 532, in __bootstrap_inner 
    File "threading.pyc", line 484, in run 
    File "webcam.py", line 66, in loop 
    File "ImageStat.pyc", line 50, in __init__ 
    File "PIL\Image.pyc", line 990, in histogram 
TypeError: argument 2 must be ImagingCore, not ImagingCore 

下面是一些代碼:

#webcam.py 
      cam = VideoCapture.Device(); 
      def getImage(): 
      return cam.getImage(); 
    ... 
     camshot = grayscale(getImage()); 
     lightCoords = []; 
     level = camshot.getextrema()[1]-leniency; 
     for p in camshot.getdata(): 
      if p>=level: 
      lightCoords.append(255); 
      else: 
      lightCoords.append(0); 
     maskIm = new("L",res); 
     maskIm.putdata(lightCoords); 
    ... 

    64  colorcamshot = getImage(); 
    65  camshot = grayscale(colorcamshot); 
    66  brightness = ImageStat.Stat(camshot,maskIm).sum[0]/divVal; 

回答

0

開始任何工作線程之前嘗試在你的主線程進口PIL。它看起來像同一個類已經被導入了兩次,並且類型比較因此而變得古怪。

相關問題