简体   繁体   中英

(Windows 10 64 bits) Py to Exe Error Python 3.8 (Pyinstaller, cx_Freeze)

Hi I'am a new python user please excuse my python basic level.

I have to update 26/10/2020 the Title to Windows 10 64bits, do to the fact that I have done the downgrade to 3.7 and the error is the same. The EXE file just blinks and closes.

I simplify the code to just the screen, using only the frame, and the same result, EXE just blinks and closes.

I think that the error is related to Pyinstaller and Windows 10 64 bits problems.

I am trying to create an EXE file from Py using Pyhton 3.8 unsuccessfully, using pyinstaller and/or cx_Freeze getting the same errors.

Several errors related to the.png, .ico access and even deleting this from the code, a simple screen with a frame does not open.

Please somebody can help me to solve this.

This is the code, I need to create onefile.exe using.PNG as Background and.ICO on the screen not only as.exe file icon.

from tkinter import *
root=Tk()

#set windows size
root.resizable(width=False, height=False)
root.geometry("925x722")

#set title
root.title("SOFT1)")

#frame 1
f1=Frame(root, width=345,height=475,bg="light 
grey",highlightbackground="black",highlightthickness=4)
f1.place(x=20,y=235)

#set a image as BG
Logo=PhotoImage(file="fileIMG.png")
lab6=Label(root, image=Logo)
lab6.place(x=0, y=0)

Currently python 3.8 isn't supported by pyinstaller. I believe cx_Freeze does, but if you don't need any specific feature from python 3.8 then I would downgrade to python 3.7 and try using pyinstaller again. Simpler that way.

There aren't any specific errors for me to base my answer off of, but I'll show you my usual approach to fixing pyinstaller issues. First, I would run the pyinstaller command with the option --debug=all. By using this option, you can see all that goes on behind the scenes when you try and run your program. Then try running the.exe file from the command line, and redirect standard error to a text file:

>your_program_here.exe 2> error.txt

If you look inside error.txt, you should see a lot of information. The most important thing to look for is a program trace-back. It's the same kind of trace-back you'll see when there's an error in the python program you're running. the trace-back will show you which line in your code is raising an error, which is usually the culprit of why your.exe won't work.

Looking from your code, I would try using absolute file paths to open your images. Right now you have it so Pet_toolShare.png is opened from the same folder that your python file is run from. Pyinstaller places the.exe in the "dist" folder so it wouldn't be able to access any files from outside of it unless you place the.exe in the same folder as your images.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM