无法运行Py2exe生成的.exe文件

时间:2016-10-24 00:11:26

标签: python executable py2exe

嗯,这是我的代码:

import tkinter

from openpyxl import load_workbook
from tkinter import filedialog
root = tkinter.Tk()
root.withdraw()

myFormats = [('.XLSX','*.xlsx')]
filename = filedialog.askopenfilename(parent=root,title='Escolha uma planilha de imóveis',multiple=False,filetypes=myFormats)
if len(filename)>0:
    print("Arquivo escolhido ->",filename)

def pegar_nome_sheet(nome_arquivo):
    nome_sheet = nome_arquivo.replace(nome_arquivo[-5:len(nome_arquivo)], "")
    nome_sheet = nome_sheet.replace(nome_sheet[0:len(nome_sheet)-18], "")
    return nome_sheet

planilha = load_workbook(filename)
sheet = planilha.get_sheet_by_name(pegar_nome_sheet(filename))
refs = []

z=0
for rowOfCellObjects in sheet['A2':sheet.max_row]:
    for cellObj in rowOfCellObjects:
        refs.insert(z,cellObj.value)
        z+=1

def gerar_rd(qtd):
    rds = []
    rd_atual = 1
    n = 0
    while rd_atual <= qtd:
        ref = "RD" + "0" * (6 - len(str(rd_atual))) + str(rd_atual)
        rds.insert(n, ref)
        n += 1
        rd_atual += 1
    return rds

todas = gerar_rd(450)

for i in refs:

    if i in todas:
        todas.remove(i)

print("Referências vazias:")

for i in todas:
    print(i)

local = filedialog.askdirectory(parent=root, title="Escolha um local para salvar o arquivo")
arq = open(local + "/Referências Vazias.txt", "w")
for i in todas:
    arq.write(i + "\n")
arq.close()

它将Excel文件中的特定数据转换为.txt文件。我试图让它可执行,所以我可以在另一台计算机(也是Windows)中运行。我试过的最后一个是Py2exe。这是我的 setup.py 文件:

from distutils.core import setup
import py2exe

setup(console=['rdsvazios.py'])

Py2exe生成我的.exe但它根本不起作用。 This is what I get when I try to execute it

我该怎么办?

P.S。:Python 3.4 / Windows 64位

0 个答案:

没有答案