0

I've seen similar problems on different forums, but none applies to this.

I have two files, one 'main.py' and the main program 'xlsKonverter.py' which I want to use cx_freeze to compile to an .exe file. When building the .exe I get this error message:

pywintypes.error: (110, 'EndUpdateResource', 'The system cannot open the device or file specified.')

And when trying to run the (somewhat finished) build, this Exception pops up:

enter image description here

I've tested all of my code, so the error is not there. It must be somewhere within the setup file. Am I wrong? And what would be a good fix?


'setup.py'

This is my cx_freeze setup

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'

, my main function

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()

and the imports from 'xlsKonverter.py'

import xlrd
import glob
import sys
4

1 回答 1

1

尝试在 main.py 文件中添加编码声明。这是一条看起来像这样的评论:

# encoding: cp1252

您可能必须根据保存文件的方式更改最后一位。如果是在 Windows 上创建的,cp1252 在西欧是正常的。在 Linux 和 Mac 上,utf8更为常见。

于 2013-07-29T13:53:19.227 回答