0

So I recently managed to convert a .py file into .exe but the problem is that the .exe file wont open properly. Basically what happens is the command prompt opens for a second and then shows some code for 1 milisecond and closes. I did manage to get a screenshot of what the command prompt says.This keeps happening when I try to open it but not with just that file, but every .py file I convert into .exe

I made a simple code to check if it was only like that for my previous code but its for every code that I make. I also used PyInstaller to convert the .py file into a .exe

import customtkinter as tk
import sys
import os

root = tk.CTk()
root.state('zoomed')
root.wm_title("Test File")

frame = tk.CTkFrame(master=root, height=300, width=600)
frame.pack_propagate(0)
frame.pack(pady=200)`

lbl = tk.CTkLabel(master=frame, text="I like chicken nuggets.", font=("Bahnschrift", 30))
lbl.pack(pady=120)

root.mainloop()

If something is unclear about my explanation, please ask. Im on Windows 11 and I use VS Code.

I asked for help on Discord but no luck. Im hoping somebody could help me here. I want my .exe file to open up like a charm and do its job.

Yaman Jain
  • 1,254
  • 11
  • 16
zds_py
  • 1
  • 2

2 Answers2

0

I suggest using auto-py-to-exe since it's easier to use. To install type this:

pip install auto-py-to-exe

To run type this:

auto-py-to-exe

Then you'll see something like this: Example Image

  • Add the path to your script and you can change any setting you want
  • Then you'll need to add the path to your custontkinter package
  • Go to Additional Files -> Add Folder -> locate your python folder -> Lib -> site-packages -> customtkinter and add it to your exe
  • Scroll down and you'll see this button. Press it and your exe should work Example Image
YoutuberTom
  • 56
  • 1
  • 2
  • The installing works but if i type "auto-py-to-exe" to open it, it says "unknown command" – zds_py Dec 26 '22 at 16:08
  • Have you added the python folder to the path? If no, you can do it by open search box and type: "Edit the system environment variables" then add your python folder to the path. I couldn't try it on Windows 11 though but it works on Windows 10 – YoutuberTom Dec 29 '22 at 10:01
0

I have not worked with customtkinter, but I think the problem you are facing might be because the blue.json file is not getting packaged along with the whole excutable that you are trying to create and secondly where you mentioned that the command "auto-py-to-exe" is not working. I think that it will be better if you use Command Prompt in Administrator Mode and then try to use auto-py-to-exe. And then hopefully if it works, as @YoutubeTom mentioned, that "Go to Additional Files -> Add Folder -> locate your python folder -> Lib -> site-packages -> customtkinter and add it to your exe". I think this will ensure that the blue.json file gets packaged as a part of your .exe file in the dist-> appfolder

PeaBee
  • 3
  • 4