問題

使用我的應用程式,應該可以使用我的程式開啟檔案.但是當我點選myfile ..MFT>開啟> myexe_to_open_mft.exe然後exe收到錯誤:致命錯誤,故障執行指令碼.如果我在沒有開啟的情況下開啟程式常規,我沒有錯誤,如果我透過命令提示開啟它,我也沒有錯誤. 謝謝你的幫助!

(編輯:最後我透過ctypeshed控制檯來修復此錯誤)

 pyinstaller --windowed -i icon.ico PickleViewer.py
 

如果在命令列上執行,則從指令碼中執行影象

錯誤螢幕截圖

python – pyinstaller的輸出

 162 INFO: PyInstaller: 3.5
162 INFO: Python: 3.7.4
163 INFO: Platform: Windows-10-10.0.18362-SP0
173 INFO: wrote 
C:\Users\user\Documents\Python\Documents\pickle_viewer\PickleViewer.spec
177 INFO: UPX is not available.
179 INFO: Extending PYTHONPATH with paths
['C:\Users\user\Documents\Python\Documents\pickle_viewer',
'C:\Users\user\Documents\Python\Documents\pickle_viewer']
180 INFO: checking Analysis
199 INFO: Building because 
C:\Users\user\Documents\Python\Documents\pickle_viewer\PickleViewer.py 
changed
200 INFO: Initializing module dependency graph...
206 INFO: Initializing module graph hooks...
211 INFO: Analyzing base_library.zip ...
5148 INFO: running Analysis Analysis-00.toc
5191 INFO: Adding Microsoft.Windows.Common-Controls to dependent 
assemblies of final executable
required by c:\users\userppdata\local\programs\python\python37- 
32\python.exe
8448 INFO: Caching module hooks...
8463 INFO: Analyzing 
C:\Users\user\Documents\Python\Documents\pickle_viewer\PickleViewer.py
8789 INFO: Loading module hooks...
8789 INFO: Loading module hook "hook-encodings.py"...
8936 INFO: Loading module hook "hook-pydoc.py"...
8938 INFO: Loading module hook "hook-xml.py"...
9298 INFO: Loading module hook "hook-_tkinter.py"...
9871 INFO: checking Tree
9931 INFO: checking Tree
9984 INFO: Looking for ctypes DLLs
9985 INFO: Analyzing run-time hooks ...
9989 INFO: Including run-time hook 'pyi_rth__tkinter.py'
9996 INFO: Looking for dynamic libraries
17315 INFO: Looking for eggs
17316 INFO: Using Python library 
c:\users\userppdata\local\programs\python\python37-32\python37.dll
17316 INFO: Found binding redirects:
[]
17331 INFO: Warnings written to 
C:\Users\user\Documents\Python\Documents\pickle_vieweruild\PickleViewer\
warn 
-PickleViewer.txt
17397 INFO: Graph cross-reference written to 
C:\Users\user\Documents\Python\Documents\pickle_vieweruild\PickleViewer\xre 
f-PickleViewer.html
17499 INFO: checking PYZ
17501 INFO: Building because toc changed
17502 INFO: Building PYZ (ZlibArchive) 
C:\Users\user\Documents\Python\Documents\pickle_vieweruild\PickleViewer\PYZ 
-00.pyz
18467 INFO: Building PYZ (ZlibArchive) 
C:\Users\user\Documents\Python\Documents\pickle_vieweruild\PickleViewer\
PYZ- 
00.pyz completed successfully.
18499 INFO: checking PKG
18501 INFO: Building because 
C:\Users\user\Documents\Python\Documents\pickle_vieweruild\PickleViewer\PYZ 
-00.pyz changed
18502 INFO: Building PKG (CArchive) PKG-00.pkg
18549 INFO: Building PKG (CArchive) PKG-00.pkg completed successfully.
18554 INFO: Bootloader c:\users\userppdata\local\programs\python\python37- 
32\lib\site- 
packages\PyInstallerootloader\Windows-32bit
unw.exe
18554 INFO: checking EXE
18556 INFO: Building because console changed
18556 INFO: Building EXE from EXE-00.toc
18651 INFO: Copying icons from ['icon.ico']
18754 INFO: Writing RT_GROUP_ICON 0 resource with 20 bytes
18755 INFO: Writing RT_ICON 1 resource with 22767 bytes
19067 INFO: Appending archive to EXE 
C:\Users\user\Documents\Python\Documents\pickle_vieweruild\PickleViewer\
Pick 
leViewer.exe
19249 INFO: Building EXE from EXE-00.toc completed successfully.
19266 INFO: checking COLLECT
WARNING: The output directory 
"C:\Users\user\Documents\Python\Documents\pickle_viewer\dist\PickleViewer" 
and ALL ITS CONTENTS will be REMOVED! Continue? (y/N)y
21243 INFO: Removing dir 
C:\Users\user\Documents\Python\Documents\pickle_viewer\dist\PickleViewer
21736 INFO: Building COLLECT COLLECT-00.toc
33512 INFO: Building COLLECT COLLECT-00.toc completed successfully.
 

  最佳答案

我知道這個錯誤,“致命錯誤,無法執行指令碼”

這個錯誤是因為您將python指令碼(.pyw not .py)編譯為.exe格式,但在該指令碼中沒有GUI可用.所以您必須使用’py’擴充套件(在Pyinstaller中,不輸入’-W’)或使用PyGame,PyQT等.

Tkinter與.pyw擴充套件不相容,所以您應該使用 python – Pygame或PyQt或GUI的其他大庫

  相同標籤的其他問題

pythonpyinstaller