0

I am new to python and tkinter, but I made a Hangman game that uses two external text documents to get words (easy and hard). I want to convert it to .exe but when I try to use auto-py-to-exe, after it finishes converting, the .exe always gives a fatal error. I have tried a variety of settings (one file, one directory, including the text documents as additional files, etc) but the same thing occurs everytime. Any suggestions for settings to use to make it work or other methods to accomplish this?

Thanks!

Dima Chubarov
  • 16,199
  • 6
  • 40
  • 76

2 Answers2

0

you could do

file=open("./file.py","r")
content=file.read()
file.close()

file=open("./newfile.txt","w")
file.write(content)
file.close()

I think it will work

Have a nice day X)

wartonbega
  • 129
  • 6
  • could u explain what dis is ? – Delrius Euphoria Jul 20 '20 at 20:39
  • Yes of course : in python open means that you open a file : file=open("file","r"). The "r" means how you open your file : 'r' = read only, 'w' = write only. You can find a lot of documentation online here --> https://docs.python.org/2/library/functions.html#open – wartonbega Jul 20 '20 at 22:51
  • i mean how is this supposed to help here – Delrius Euphoria Jul 21 '20 at 04:35
  • This is not a real convertion, but you create a second file in .exe. You can then delete the first one (the .py) and you get the same result if you just convert your file. For deleting you can use --> `os.remove(file_to_remove)` and you get a nice and perfect convertion (same result). – wartonbega Jul 21 '20 at 09:31
0

What works for me when converting .py to .exe with additional imports (like tkinter) is to add "hidden-imports", it's under the "advanced" tab when you are in auto-py-to-exe.

To get it to work, add "tkinter":

enter image description here

Kemp
  • 3,467
  • 1
  • 18
  • 27
Note Salad
  • 11
  • 3