使用pyinstaller编译时出错,“加载python38.dll时出错”

时间:2020-05-26 13:45:58

标签: python python-3.x tkinter pyinstaller

我正在编译我的第一个GUI应用程序,正在使用pyinstaller,因为它是我所知道的那个,它会生成.exe文件。 我在AMD 64位上的win32上使用Python 3.8.1(tags / v3.8.1:1b293b6,2019年12月18日,22:39:24)[MSC v.1916 32位(Intel)]。

from tkcalendar import Calendar, DateEntry
from tkinter.ttk import * 
from tkinter import messagebox
from tkinter import *
import datetime
import sqlite3

然后,当我去运行exe文件时,请得到此错误,能否告诉我它所指的是什么,或者我在哪里可以找到该错误的原因,或者是否还有另一种更有效的编译方式。

>

enter image description here

enter image description here

这是编译器生成的文本,我看不懂,看不到它是否描述了我的错误。

enter image description here

enter image description here

我先感谢您的帮助,问候和感谢。如果您可以推荐我继续使用pyinstaller,或者可以推荐其他编译器,则我已经尝试进行了1周的编译,并且由于不进行升级而感到停滞,我看不到错误。

1 个答案:

答案 0 :(得分:0)

我使用cx_Freeze,并制作了一个将py转换为exe的GUI:

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!