繁体   English   中英

auto-py-to-exe 卡在加载模块钩子“hook-gevent.py”

[英]auto-py-to-exe stuck at Loading module hook 'hook-gevent.py'

我正在尝试使用 auto-py-to-exe 将代码转换为 exe。 它卡在“正在加载模块挂钩'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()

这是自动py到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'...

这里有人遇到同样的问题或知道该怎么做吗? ps:一切都应该与代码一起工作,因为它在我启动py文件时也可以工作。

简短回答后添加:

在 cmd 中执行此操作(假设您在 Windows 上)并等待 SyntaxError,会有两个但稍后它应该继续并创建 exe。 如果您找不到通过 output 读取的 exe 文件的保存位置,它应该在某个地方或谷歌上,它将它们保存在您各自的操作系统上。

编辑:对不起,我认为这是不正确的解决方案,它只是一个巧合,我会尝试找到我所做的修复它。

我和你有同样的问题,但在玩了一段时间后,我想我有一个解决方案。

我在我的 python 文件中添加了导入日志记录,并在 windows cmd 中使用了 pyinstaller 而不是 auto-py-to-exe。

我使用的命令是:

pyinstaller --noconfirm --onefile --windowed "C:/Users/user/Downloads/file.py"

您可以在 auto-py-to-exe 中设置设置并将命令复制粘贴到“当前命令”中

编辑 2:我有两个相同的 python 文件,唯一的区别是一个的名称有下划线,一个没有。 文件名中带有下划线的那个会完美地变成一个 exe,但另一个不会。

编辑 3,解决方案:我只是等待它工作,即使它在 cmd 中出现错误,这也是使用我原来的建议。 如果这不起作用,我做的另一件事是from tkinter import *更改为import tkinter as tk

该更改意味着 Tk() 变为 tk.Tk() 并且 Label 变为 tk.Label 等等。

我可以通过在 auto-py-to-exe 的排除模块中添加 gevent 来解决这个问题。 exe 已成功创建。

我遇到了类似的问题,因为我使用的是 Tkinter 接口。

我正在构建我的 exe

pyinstaller myscript.py

当建造者到达时

212207 INFO: Loading module hook "hook-gevent.py"...

tkinter window 打开,我必须关闭它才能继续构建。

我不知道为什么我的脚本在构建时正在执行。 如果有人有想法,我会很高兴。

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. 我对文件名所做的另一项更改是我已将其更改为纯小写。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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