致命错误,无法执行脚本 xyz

时间:2021-04-14 15:38:08

标签: python python-3.x windows

我正在尝试从这个脚本 (Python 3.9.2) 生成 exe。该脚本的作用是打开 Notepad.exe 并在单击 GUI(切换按钮)时终止:

from tkinter.tix import *
import subprocess

app = Tk()
tip = Balloon(app)
global State
State = 0
global file
file = subprocess.Popen(r'C:\Windows\notepad.exe')


def toggleBtn(e):
    global State
    global file
    if State == 1:
        toggle.config(image=btnon)
        file = subprocess.Popen(r'C:\Windows\notepad.exe')
        State = 0
    else:
        toggle.config(image=btnoff)
        file.terminate()
        State = 1


btnoff = PhotoImage(file="off.png")
btnon = PhotoImage(file="on.png")
lastClickX = 0
lastClickY = 0


def dragging(e):
    x, y = e.x - lastClickX + app.winfo_x(), e.y - lastClickY + app.winfo_y()
    app.geometry("+%s+%s" % (x, y))


toggle = Label(app, image=btnon)
toggle.bind("<Button-1>", toggleBtn)
toggle.pack()

tip.bind_widget(toggle, balloonmsg="Use right mouse button to move this")
app.geometry("71x31+0+839")
app.overrideredirect(True)
app.attributes('-topmost', True)
app.bind('<B3-Motion>', dragging)
app.wm_attributes("-transparentcolor", app["bg"])

app.mainloop()

但是当我得到 exe 时,它​​不执行并显示一条消息“致命错误,无法执行脚本” 我应该怎么办?创建 exe 后,输出控制台给出给定的消息:

Running auto-py-to-exe v2.8.0
Building directory: C:\Users\Poornima\AppData\Local\Temp\tmpaindtlti
Provided command: pyinstaller --noconfirm --onefile --windowed -F "C:/Users/Poornima/Desktop/hello/keynik.py"
Recursion Limit is set to 5000
Executing: pyinstaller --noconfirm --onefile --windowed -F C:/Users/Poornima/Desktop/hello/keynik.py --distpath C:\Users\Poornima\AppData\Local\Temp\tmpaindtlti\application --workpath C:\Users\Poornima\AppData\Local\Temp\tmpaindtlti\build --specpath C:\Users\Poornima\AppData\Local\Temp\tmpaindtlti

1856377 INFO: PyInstaller: 4.2
1856379 INFO: Python: 3.9.2
1856390 INFO: Platform: Windows-10-10.0.19041-SP0
1856407 INFO: wrote C:\Users\Poornima\AppData\Local\Temp\tmpaindtlti\keynik.spec
1856425 INFO: UPX is not available.
1856439 INFO: Extending PYTHONPATH with paths
['C:\\Users\\Poornima\\Desktop\\hello',
 'C:\\Users\\Poornima\\AppData\\Local\\Temp\\tmpaindtlti']
1856458 INFO: checking Analysis
1856470 INFO: Building Analysis because Analysis-04.toc is non existent
1856474 INFO: Reusing cached module dependency graph...
1856550 INFO: Caching module graph hooks...
1856573 WARNING: Several hooks defined for module 'win32ctypes.core'. Please take care they do not conflict.
1856655 INFO: running Analysis Analysis-04.toc
1856661 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
  required by c:\users\poornima\appdata\local\programs\python\python39\python.exe
1856736 WARNING: lib not found: api-ms-win-core-path-l1-1-0.dll dependency of c:\users\poornima\appdata\local\programs\python\python39\python39.dll
1856805 INFO: Analyzing C:\Users\Poornima\Desktop\hello\keynik.py
1856877 INFO: Processing module hooks...
1856879 INFO: Loading module hook 'hook-difflib.py' from 'c:\\users\\poornima\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\hooks'...
1856884 INFO: Excluding import of doctest from module difflib
1856898 INFO: Loading module hook 'hook-distutils.py' from 'c:\\users\\poornima\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\hooks'...
1856914 INFO: Loading module hook 'hook-distutils.util.py' from 'c:\\users\\poornima\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\hooks'...
1856917 INFO: Excluding import of lib2to3.refactor from module distutils.util
1856920 INFO: Loading module hook 'hook-encodings.py' from 'c:\\users\\poornima\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\hooks'...
1857030 INFO: Loading module hook 'hook-heapq.py' from 'c:\\users\\poornima\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\hooks'...
1857041 INFO: Excluding import of doctest from module heapq
1857055 INFO: Loading module hook 'hook-lib2to3.py' from 'c:\\users\\poornima\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\hooks'...
1857135 INFO: Loading module hook 'hook-multiprocessing.util.py' from 'c:\\users\\poornima\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\hooks'...
1857139 INFO: Excluding import of test.support from module multiprocessing.util
1857151 INFO: Excluding import of test from module multiprocessing.util
1857154 INFO: Loading module hook 'hook-pickle.py' from 'c:\\users\\poornima\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\hooks'...
1857161 INFO: Excluding import of argparse from module pickle
1857164 INFO: Loading module hook 'hook-sysconfig.py' from 'c:\\users\\poornima\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\hooks'...
1857168 INFO: Loading module hook 'hook-xml.etree.cElementTree.py' from 'c:\\users\\poornima\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\hooks'...
1857182 INFO: Loading module hook 'hook-xml.py' from 'c:\\users\\poornima\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\hooks'...
1857254 INFO: Loading module hook 'hook-_tkinter.py' from 'c:\\users\\poornima\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\hooks'...
1857455 INFO: checking Tree
1857458 INFO: Building Tree because Tree-12.toc is non existent
1857463 INFO: Building Tree Tree-12.toc
1857552 INFO: checking Tree
1857555 INFO: Building Tree because Tree-13.toc is non existent
1857563 INFO: Building Tree Tree-13.toc
1857683 INFO: checking Tree
1857690 INFO: Building Tree because Tree-14.toc is non existent
1857693 INFO: Building Tree Tree-14.toc
1857734 INFO: Looking for ctypes DLLs
1857778 INFO: Analyzing run-time hooks ...
1857790 INFO: Including run-time hook 'c:\\users\\poornima\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_multiprocessing.py'
1857797 INFO: Including run-time hook 'c:\\users\\poornima\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth__tkinter.py'
1857810 INFO: Looking for dynamic libraries
1858259 INFO: Looking for eggs
1858275 INFO: Using Python library c:\users\poornima\appdata\local\programs\python\python39\python39.dll
1858278 INFO: Found binding redirects: 
[]
1858288 INFO: Warnings written to C:\Users\Poornima\AppData\Local\Temp\tmpaindtlti\build\keynik\warn-keynik.txt
1858341 INFO: Graph cross-reference written to C:\Users\Poornima\AppData\Local\Temp\tmpaindtlti\build\keynik\xref-keynik.html
1858389 INFO: checking PYZ
1858400 INFO: Building PYZ because PYZ-04.toc is non existent
1858418 INFO: Building PYZ (ZlibArchive) C:\Users\Poornima\AppData\Local\Temp\tmpaindtlti\build\keynik\PYZ-04.pyz
1859297 INFO: Building PYZ (ZlibArchive) C:\Users\Poornima\AppData\Local\Temp\tmpaindtlti\build\keynik\PYZ-04.pyz completed successfully.
1859314 INFO: checking PKG
1859318 INFO: Building PKG because PKG-04.toc is non existent
1859322 INFO: Building PKG (CArchive) PKG-04.pkg
1861953 INFO: Building PKG (CArchive) PKG-04.pkg completed successfully.
1861987 INFO: Bootloader c:\users\poornima\appdata\local\programs\python\python39\lib\site-packages\PyInstaller\bootloader\Windows-64bit\runw.exe
1861999 INFO: checking EXE
1862004 INFO: Building EXE because EXE-04.toc is non existent
1862015 INFO: Building EXE from EXE-04.toc
1862021 INFO: Copying icons from ['c:\\users\\poornima\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\bootloader\\images\\icon-windowed.ico']
1862031 INFO: Writing RT_GROUP_ICON 0 resource with 104 bytes
1862034 INFO: Writing RT_ICON 1 resource with 3752 bytes
1862038 INFO: Writing RT_ICON 2 resource with 2216 bytes
1862045 INFO: Writing RT_ICON 3 resource with 1384 bytes
1862062 INFO: Writing RT_ICON 4 resource with 38188 bytes
1862066 INFO: Writing RT_ICON 5 resource with 9640 bytes
1862070 INFO: Writing RT_ICON 6 resource with 4264 bytes
1862078 INFO: Writing RT_ICON 7 resource with 1128 bytes
1862086 INFO: Updating manifest in C:\Users\Poornima\AppData\Local\Temp\tmpaindtlti\build\keynik\runw.exe.10smvpqt
1862095 INFO: Updating resource type 24 name 1 language 0
1862102 INFO: Appending archive to EXE C:\Users\Poornima\AppData\Local\Temp\tmpaindtlti\application\keynik.exe
1862140 INFO: Building EXE from EXE-04.toc completed successfully.

Moving project to: C:\Users\Poornima\Desktop\output
Complete.

我找不到问题出在哪里。请帮帮我!!!

0 个答案:

没有答案
相关问题