py2exe创建的exe报错
我用py2exe做了一个exe文件。在成功创建exe之后,当我运行main.exe的时候,出现了以下错误。
File "_mssql.pyc", line 12, in <module>
File "_mssql.pyc", line 10, in __load
ImportError: DLL load failed: The specified module could not be found.
我正在使用pymssql模块来连接SQL Server数据库。
1 个回答
5
确保你在 选项 字典中包含这个模块。我觉得还需要一个叫 ntwdblib.dll
的dll文件。你可以找到这个文件,并把它放到你的 setup.py
里。
import os, pymssql
from distutils.core import setup
import py2exe
dll = []
dll.append(os.path.join(os.path.split(pymssql.__file__)[0], 'ntwdblib.dll'))
pyops = {"includes": ['decimal']}
setup(console=['app.py'], options={"py2exe": pyops}, data_files=dll)