我在不同的论坛上看到过类似的问题,但没有一个适用于此。
我有两个文件,一个'main.py'和主程序'xlsKonverter.py',我想用cx_freeze编译成.exe文件。构建.exe时,我收到以下错误消息:
pywintypes.error: (110, 'EndUpdateResource', 'The system cannot open the device or file specified.')
当尝试运行(稍微完成)构建时,会弹出此异常:
我已经测试了所有代码,因此错误不存在。它必须位于安装文件中的某个位置。我错了吗?什么是一个很好的解决方案?
'setup.py'
这是我的cx_freeze设置
import sys
from cx_Freeze import setup, Executable
build_exe_options = {"packages": ["os"], "excludes": ["tkinter"]}
packages = ['xlrd', 'glob', 'sys']
includes = ['xlsKonverter']
includefiles = []
eggsacutibull = Executable(
script = "main.py",
base = 'Console',
initScript = None,
targetName = "main.py",
compress = True,
copyDependentFiles = True,
appendScriptToExe = False,
appendScriptToLibrary = False,
icon = None
)
setup( name = "Table Converter",
version = "0.3",
author = "Jørgen Sirhaug",
description = "Makes a .csv file from designated Wire List.",
options = {"build_exe": build_exe_options},
executables = [eggsacutibull]
)
'main.py'
,我的主要功能
import xlsKonverter as xk
import os.path
import sys
def main():
fileList = xk.getAllFileURLsInDirectory("C:\\Users\\Jørgen\\Dropbox\\Aker\\Wire Lists\\")
if len(fileList) < 1:
print("ERROR! No files in directory!\nDoes the specified folder excist?")
else:
print('')
for i in range(len(fileList)):
try:
sheet = xk.getWorksheet(fileList[i])
tagCols = xk.automaticFirstRow(sheet)
pairedList = xk.pairCells(sheet, tagCols)
csvString = xk.makecsv(pairedList)#, tagCols)
xk.writeToFile(csvString, i)
except:
print("ERROR!\n" + fileList[i] + '\nThis file does not excist!')
main()
和'xlsKonverter.py'的导入
import xlrd
import glob
import sys
答案 0 :(得分:1)
尝试在main.py文件中放置编码声明。这是一个看起来像这样的评论:
# encoding: cp1252
您可能需要更改最后一位,具体取决于您保存文件的方式。如果它是在Windows上创建的,则cp1252对于西欧来说是正常的。在Linux和Mac上,utf8
更常见。