我正在构建一个简单的python 3.5.2脚本,它导入了pyrebase(firebase库),tkinter和openpyxl
来自pycharm或cmd的脚本独立运行完美。
我试图为它生成一个exe,我尝试使用很多组合python3.4 - python3.6,py2exe,pyinstaller,cx_Freeze,没有什么对我有用。
我现在尝试的最后一件事是pyinstaller - python 3.5.2 现在我使用pyigaller来执行gui https://github.com/brentvollebregt/auto-py-to-exe
构建完成成功,当我尝试从cmd:python file.exe运行时出现错误:
SyntaxError: Non-UTF-8 code starting with '\x90' in file output\EMAInnerSpeechMain.exe on line 1
虽然我有
# coding: utf-8
在我的代码中
尝试从cmd:file.exe运行时出现以下错误:
File "site-packages\Crypto\Util\_raw_api.py", line 168, in load_pycryptodome_raw_lib
OSError: Cannot load native module 'Crypto.Hash._SHA256'
我已尝试在互联网中找到的所有内容,以便从我的脚本中构建一个exe,但我没有成功,请帮助
我的代码:
# coding: utf-8
import sys
from tkinter import *
from tkinter import filedialog
import datetime
from openpyxl import Workbook
from openpyxl.styles import colors
from openpyxl.styles import Font, Color
import pyrebase
from collections import defaultdict
config = {
"apiKey": "****",
"authDomain": "****,
"databaseURL": "****",
"storageBucket": "****"
}
f = pyrebase.initialize_app(config)
firebaseData = f.database()
firebaseStorage = f.storage()
root = Tk()
welcomeLabel = Label(root, text="Please fill in \"path\" where you want data to be exported\n"
"and press export to excel button to start", anchor=W, justify=LEFT)
welcomeLabel.grid(row=0, sticky=W, padx=10, pady=10)
pathLabelBase = "Path: "
pathLabel = Label(root, text=pathLabelBase, anchor=W, justify=LEFT)
pathLabel.grid(row=1, column=0, sticky=W, padx=10, pady=10)
statusLabel = Label(root, text="", anchor=W, justify=LEFT)
statusLabel.grid(row=3, sticky=W, padx=10, pady=10)
def browsefunc():
dirName = filedialog.askdirectory()
if dirName != "":
statusLabel.config(text="")
pathLabel.config(text=pathLabelBase + dirName)
browseButton = Button(root, text="Browse", command=browsefunc)
browseButton.grid(row=1, column=1, sticky=W, padx=10, pady=10)
def exportToExcel():
dirPath = pathLabel.cget("text")
if pathLabelBase == dirPath:
statusLabel.config(text="Please choose directory to export excel file to.\nBy clicking on \"Browse\" button.",
fg="red")
return
...fetching data from firebase and creating excel file
exportButton = Button(root, text="Export to excel", fg="blue", command=exportToExcel)
exportButton.grid(row=2, column=1, sticky=W, columnspan=2, padx=10, pady=10)
root.mainloop()
感谢任何帮助!
提前致谢
答案 0 :(得分:0)
您可以尝试使用auto-py-to-exe。首先,打开cmd,然后键入:
pip install auto-py-to-exe 安装完成后 在cmd中键入auto-py-to-exe
答案 1 :(得分:0)
您需要创建一个名为“hook-gclod.py”的钩子文件并将以下代码放入其中:-
from PyInstaller.utils.hooks import copy_metadata
datas = copy_metadata('gcloud')
执行此操作后,将其放入文件夹中,使用以下命令构建您的 exe:-
pyinstaller --noconfirm --onefile --console --additional-hooks-dir "path to folder with the hook file" "path of your script"