使用py2exe的ctypes的exe文件出错

时间:2014-12-29 11:41:05

标签: python pyside py2exe

在mainwindow.py文件中,我使用了这一行,

ctypes.windll.LoadLibrary("ptzdll/PTZ.dll")
from PTZ import PTZDevice, PTZType

当我用终端(python mainwindow.py)执行mainwindow.py文件时,它可以工作,但是当我双击py2exe生成的exe文件时,它会出错:

**No module named PTZ.**

我的setup.py文件代码:

from distutils.core import setup
from glob import glob
import py2exe

from distutils.filelist import findall
import matplotlib
import cv2
import numpy
import tkMessageBox
import easygui
import os



datafiles = [
        ("resources", glob('resources/*.*'))
]


datafiles.append(('ptzdll', [
                'PTZ.dll',
                'DirectShowLib-2005.dll'
                ]))    

setup(
        console=['mainwindow.py'],
        #'file_resources': [bitmap_string[:-1]],

        options = {
                    'py2exe': {
                    'packages' : ['matplotlib','ctypes','_ctypes'],
                    'dll_excludes': ['libgdk-win32-2.0-0.dll', 
                                     'libgobject-2.0-0.dll', 
                                     'libgdk_pixbuf-2.0-0.dll'],
                    r'includes': [r'scipy.sparse.csgraph._validation',
                                  r'scipy.special._ufuncs_cxx']
                                }
                    },
        zipfile = None,
        windows = [{
                    "script":"mainwindow.py",
                    "icon_resources":[(1, "tfr.ico")],

                    }],
        data_files = datafiles,
        #data_files = datafiles
        )

1 个答案:

答案 0 :(得分:0)

PTZ.dll不在* \ dist \ ptzdll文件夹中,但在* \ dist \ library.zip \ ptzdll \ PTZ.dll中。