使用cz_freeze将py转换为exe

时间:2018-03-12 10:36:32

标签: python pyinstaller py2exe cx-freeze

我正在尝试将我的python文件转换为exe文件。目前我正在使用cz_freeze,但它不起作用。虽然没有错误但是应该创建的构建目录没有发生。

PS:不确定它是否相关,但我在mac系统上的虚拟盒上运行Windows。

这是我的setup.py文件

from cx_Freeze import setup, Executable
import sys

base = None

if sys.platform == 'win32':
    base = None


executables = [Executable("untitled.py", base=base)]

packages = ["idna"]
options = {
    'build_exe': {

        'packages':packages,
    },

}

setup(
    name = "<any name>",
    options = options,
    version = "<any number>",
    description = '<any description>',
    executables = executables
)

这是我的主文件(untitled2.py)

import quickstart

a=input("username:")
b=input("samrat_id")
c=input("true:")
def function():
    quickstart.update_spreadsheet(a,b,c)
function()

这是我在我的main untitled2.py文件中导入的另一个python文件

import gspread
import os
import datetime
import time


from oauth2client.service_account import ServiceAccountCredentials

#to find next available row 
def next_available_row(sheet):
    str_list = list(filter(None, sheet.col_values(1)))  # fastest
    return str(len(str_list)+1)

# use creds to create a client to interact with the Google Drive API
def update_spreadsheet(username,SAMRAT_id,test_result):
    scope = ['https://spreadsheets.google.com/feeds']
    basedir = os.path.abspath(os.path.dirname(__file__))
    DATA_JSON = basedir+'/'+'client_secret.json'
    creds = ServiceAccountCredentials.from_json_keyfile_name(DATA_JSON, scope)

    client = gspread.authorize(creds)

    # Find a workbook by name and open the first sheet
    # Make sure you use the right name here.
    sheet = client.open("TESTING REPORT")
    worksheet=sheet.worksheet("INTEGRATION TEST")
    next_row = next_available_row(worksheet)



    count=int(next_row)
    count-=1


    #insert on the next available row
    date_today=datetime.date.today()
    time_today=time.strftime("%H:%M:%S")

    worksheet.update_acell("A{}".format(next_row), count)
    worksheet.update_acell("B{}".format(next_row), date_today)
    worksheet.update_acell("C{}".format(next_row), time_today)
    worksheet.update_acell("D{}".format(next_row), SAMRAT_id)
    worksheet.update_acell("E{}".format(next_row), test_result)
    worksheet.update_acell("G{}".format(next_row), username)

我还有一个json文件,我在quickstart.py文件中加载,这是程序运行所必需的。请免费提出另一个转换器。

0 个答案:

没有答案