'auto-py-to-exe stuck at Loading module hook 'hook-gevent.py'
I am trying to convert the code to exe with auto-py-to-exe. It stuck at "Loading module hook 'hook-gevent.py'...".
import time, pyautogui, keyboard, threading
from tkinter import *
window = Tk()
window.title('KONG Spammer')
window.resizable(False, False)
def clickedStart():
time.sleep(2.5)
for i in range(int(txt2.get())):
strDelay = txt3.get()
floatDelay = float(strDelay)
time.sleep(floatDelay)
pyautogui.write(txt.get())
pyautogui.press('enter')
lbl = Label(window, text='Spam message:', font=('segoe script', 18), background='orange', justify=CENTER)
lbl.grid(column=10, row=0, padx=(35, 10))
txt = Entry(window, width=10)
txt.grid(column=10, row=1, padx=(35, 10))
txt.insert(END, 'message')
lbl2 = Label(window, text='Spam amount:', font=('segoe script', 18), background='orange', justify=CENTER)
lbl2.grid(column=10, row=2, padx=(35, 10))
txt2 = Entry(window, width=10)
txt2.grid(column=10, row=3, padx=(35, 10))
txt2.insert(END, 'amount')
lbl3 = Label(window, text='Spam delay:', font=('segoe script', 18), background='orange', justify=CENTER)
lbl3.grid(column=10, row=4, padx=(35, 10))
txt3 = Entry(window, width=10)
txt3.grid(column=10, row=5, padx=(35, 10))
txt3.insert(END, 'delay')
btn = Button(window, text='Start', command=clickedStart, bg='green', fg='white')
btn.grid(column=10, row=6, padx=(35, 10), pady=(15,10))
window.geometry('275x275')
window.configure(bg='orange')
icon = PhotoImage(file = 'appIcon.png')
window.iconphoto(False, icon)
txt.focus()
window.mainloop()
Here is the log of auto-py-to-exe:
Running auto-py-to-exe v2.8.0
Building directory: C:\Users\Floom\AppData\Local\Temp\tmpx8agn6z6
Provided command: pyinstaller --noconfirm --onedir --windowed --icon "F:/Downloads/KONGSpammer.ico" --add-data "F:/Dokumente/code/appIcon.png;." "F:/Dokumente/code/KONGSpammer.py"
Recursion Limit is set to 5000
Executing: pyinstaller --noconfirm --onedir --windowed --icon F:/Downloads/KONGSpammer.ico --add-data F:/Dokumente/code/appIcon.png;. F:/Dokumente/code/KONGSpammer.py --distpath C:\Users\Floom\AppData\Local\Temp\tmpx8agn6z6\application --workpath C:\Users\Floom\AppData\Local\Temp\tmpx8agn6z6\build --specpath C:\Users\Floom\AppData\Local\Temp\tmpx8agn6z6
33831 INFO: PyInstaller: 4.3
33845 INFO: Python: 3.9.4
33861 INFO: Platform: Windows-10-10.0.19041-SP0
33876 INFO: wrote C:\Users\Floom\AppData\Local\Temp\tmpx8agn6z6\KONGSpammer.spec
33893 INFO: UPX is not available.
33901 INFO: Extending PYTHONPATH with paths
['F:\\Dokumente\\code', 'C:\\Users\\Floom\\AppData\\Local\\Temp\\tmpx8agn6z6']
33914 INFO: checking Analysis
33922 INFO: Building Analysis because Analysis-00.toc is non existent
33938 INFO: Initializing module dependency graph...
33941 INFO: Caching module graph hooks...
33960 WARNING: Several hooks defined for module 'win32ctypes.core'. Please take care they do not conflict.
33973 INFO: Analyzing base_library.zip ...
35566 INFO: Processing pre-find module path hook distutils from 'c:\\users\\floom\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\hooks\\pre_find_module_path\\hook-distutils.py'.
35583 INFO: distutils: retargeting to non-venv dir 'c:\\users\\floom\\appdata\\local\\programs\\python\\python39\\lib'
37487 INFO: Caching module dependency graph...
37608 INFO: running Analysis Analysis-00.toc
37626 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
required by c:\users\floom\appdata\local\programs\python\python39\python.exe
37679 WARNING: lib not found: api-ms-win-core-path-l1-1-0.dll dependency of c:\users\floom\appdata\local\programs\python\python39\python39.dll
37814 INFO: Analyzing F:\Dokumente\code\KONGSpammer.py
39677 INFO: Processing pre-safe import module hook urllib3.packages.six.moves from 'c:\\users\\floom\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\hooks\\pre_safe_import_module\\hook-urllib3.packages.six.moves.py'.
40780 INFO: Processing pre-find module path hook site from 'c:\\users\\floom\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\hooks\\pre_find_module_path\\hook-site.py'.
40795 INFO: site: retargeting to fake-dir 'c:\\users\\floom\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\fake-modules'
41583 INFO: Processing pre-safe import module hook setuptools.extern.six.moves from 'c:\\users\\floom\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\hooks\\pre_safe_import_module\\hook-setuptools.extern.six.moves.py'.
44164 INFO: Processing module hooks...
44176 INFO: Loading module hook 'hook-certifi.py' from 'c:\\users\\floom\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
44181 INFO: Loading module hook 'hook-cv2.py' from 'c:\\users\\floom\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
44193 INFO: Loading module hook 'hook-eel.py' from 'c:\\users\\floom\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
44276 INFO: Loading module hook 'hook-pycparser.py' from 'c:\\users\\floom\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
44285 INFO: Loading module hook 'hook-win32ctypes.core.py' from 'c:\\users\\floom\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
44428 INFO: Loading module hook 'hook-difflib.py' from 'c:\\users\\floom\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\hooks'...
44433 INFO: Loading module hook 'hook-distutils.py' from 'c:\\users\\floom\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\hooks'...
44435 INFO: Loading module hook 'hook-distutils.util.py' from 'c:\\users\\floom\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\hooks'...
44441 INFO: Loading module hook 'hook-encodings.py' from 'c:\\users\\floom\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\hooks'...
44515 INFO: Loading module hook 'hook-gevent.py' from 'c:\\users\\floom\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\hooks'...
Is there someone here who had the same problem or knows what to do? ps: Everything should work with the code, because it also works when I start the py file.
Solution 1:[1]
Short answer added after:
Do it in cmd (assuming you're on windows) and wait out the SyntaxError, there will be two but after a bit it should move on and create the exe. If you can't find where it saved the exe read through the output and it should be in there somewhere or google where it saves them on your respective operating system.
Edit: Sorry, I think that this is incorrect solution and it is just a coincidence that it worked, I will try and find what I did to fix it.
I had the same problem as you but after a bit of playing around I think I have a solution.
I added import logging to my python file and used pyinstaller in windows cmd instead of auto-py-to-exe.
The command I used was:
pyinstaller --noconfirm --onefile --windowed "C:/Users/user/Downloads/file.py"
You can set up the settings in auto-py-to-exe and copy paste the command in "Current Command"
Edit 2: I have two identical python files, the only difference is the name of one has underscores in and one doesn't. The one with underscores in the file name turns into an exe perfectly but the other doesn't.
Edit 3, solution: I just waited and it worked even though it gave an error in the cmd, that is using my original advice as well. If that doesn't work another thing I did is change from tkinter import *
to import tkinter as tk
.
That change means Tk() becomes tk.Tk() and Label becomes tk.Label and so on.
Solution 2:[2]
I was able to solve this issue by adding gevent in the exclude-module of auto-py-to-exe. Exe was successfully created.
Solution 3:[3]
I had a similar issue because I was using a Tkinter interface.
I was building my exe with
pyinstaller myscript.py
when the builder arrive at
212207 INFO: Loading module hook "hook-gevent.py"...
The tkinter window open and I have to close it to continue the build.
I don't know why my script is executing while building. If anyone has an idea I would be glad.
Solution 4:[4]
I faced the same error and tried all the possible solutions on stackoverflow and at last I copy pasted the same code in another file and ran the cmd pyinstaller filename.py in anaconda powershell prompt instead anaconda prompt and it worked. One more change I have done to the filename is that I have changed it into pure lowercase.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | Suryan S |
Solution 3 | CestplusRasti Moens de Hase |
Solution 4 | Gumadavelly Ramya |