Python PIL ImageStat.Stat上的py2exe引发异常:参数2必须是ImagingCore,而不是ImagingCore

Python PIL ImageStat.Stat上的py2exe引发异常:参数2必须是ImagingCore,而不是ImagingCore,python,python-imaging-library,py2exe,Python,Python Imaging Library,Py2exe,我试图使用py2exe从python程序中创建一个.exe,但当我运行该.exe时,会得到一个带有 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

我试图使用py2exe从python程序中创建一个.exe,但当我运行该.exe时,会得到一个带有

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;

在启动任何工作线程之前,请尝试在主线程中导入PIL。看起来同一个类已经被导入了两次,因此类型比较显得很奇怪