问题描述:

Well, this is my code:

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

It takes specific data from an Excel file to a .txt file. I'm trying to make it executable, so I could run in another computer (also Windows). The last one I tried was Py2exe. This is my setup.py file:

from distutils.core import setup

import py2exe

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

Py2exe generates my .exe but it doesn't work at all.

This is what I get when I try to execute it

What can I do?

P.S.: Python 3.4 / Windows 64 bits

相关阅读:
Top