使用pyinstaller编译出错,“加载python38.dll时出错";
我正在编译我的第一个 GUI 应用程序,我正在使用 pyinstaller,因为它是我所知道的,它生成 .exe 文件.我在 AMD 64 位的 win32 上使用 Python 3.8.1(标签/v3.8.1:1b293b6,2019 年 12 月 18 日,22:39:24)[MSC v.1916 32 位(英特尔)].
I am compiling my first GUI Application, I am using pyinstaller because it is the one I know, it generates the .exe file. I am using Python 3.8.1 (tags / v3.8.1: 1b293b6, Dec 18 2019, 22:39:24) [MSC v.1916 32 bit (Intel)] on win32 on AMD 64Bits.
from tkcalendar import Calendar, DateEntry
from tkinter.ttk import *
from tkinter import messagebox
from tkinter import *
import datetime
import sqlite3
然后,当我去运行 exe 文件时,我收到此错误,请告诉我它指的是什么或在哪里可以找到错误的内容,或者是否有另一种更有效的编译方法.
Then when I go to run the exe file I get this error, please, can you tell me what it refers to or where I can find what the error is about or if there is another more effective way to compile.
这是编译器生成的文本,我看不懂,看是不是描述了我这里的错误.
This is the text generated by the compiler, I can't read it, I don't see if it describes the error I have here.
我提前感谢任何帮助、问候和感谢.如果你能推荐我继续使用pyinstaller,或者你能推荐其他编译器,我尝试编译了1周,感觉停滞不前,因为我没有前进,我没有收到错误.
I appreciate any help, greetings and thanks in advance. If you can recommend me to continue with pyinstaller or if you can recommend another compiler, I have been trying to compile for 1 week and I feel stagnant since I do not advance, I do not get the error.
我使用 cx_Freeze 并制作了一个将 py 转换为 exe 的 GUI :
I use cx_Freeze and I made a GUI which converts py to exe :
import os
import time
from tkinter import *
from tkinter.filedialog import askopenfile
from tkinter.scrolledtext import ScrolledText
from tkinter.messagebox import *
tk = Tk()
tk.title(".py -> .exe")
tk.resizable(0, 0)
f = None
def browse():
global f, btn
try:
f = askopenfile().name # get the py file
btn["text"] = os.path.basename(f)
except:
f = None
def convert():
global f, btn, ver, des
OK = False
try:
dots = 0
for x in ver.get(): # check the number of dots in version
if x == ".":
dots += 1
else:
x = int(x)
if dots < 4:
OK = True
except:
showwarning("","The version must be int.int.int... with max 3 dots.")
if OK:
try:
if f is None:
showwarning("","You must choose a file to convert.")
btn.focus()
elif ver.get() == "":
showwarning("","You must enter a version.")
ver.focus()
else:
with open("setup.py", "w") as f_: # fill a new file setup.py (installer)
f_.write("NAME = '" + f +
"'\nVERSION = '" + ver.get() +
"'\nDESCRIPTION = \"\"\"" + des.get(1.0, "end") +
"\"\"\"\nFILENAME = '" + f +
"'\n\nfrom cx_Freeze import setup, Executable\nsetup(name = NAME, version = VERSION, description = DESCRIPTION, executables = [Executable(FILENAME)])")
with open("setup.bat", "w") as f_: # fill a new file setup.bat (installation launcher)
f_.write("py setup.py build")
os.system("setup.bat")
btn["text"] = "Browse..."
f = None
os.remove("setup.py") # remove files created in this script
os.remove("setup.bat") #
showinfo("Information","End. Your exe file is in folder 'build'.")
except:
showerror("Error","Error detected.")
# create GUI
Label(text="File to convert").grid(column=0, row=0, sticky="w")
btn = Button(text="Browse...", command=browse)
btn.grid(column=1, row=0)
Label(text="Version").grid(column=0, row=2, sticky="w")
ver = Entry()
ver.grid(column=1, row=2, padx=5)
Label(text="Description").grid(column=0, row=3, sticky="w")
des = ScrolledText(width=15, height=5, wrap=WORD)
des.grid(column=1, row=3)
Label(text="Convert to .exe").grid(column=0, row=4, sticky="w")
Button(text="Convert", command=convert).grid(column=1, row=4, pady=5)
tk.mainloop()
不要忘记安装 cx_Freeze !
Don't forget to install cx_Freeze !