[英]Pyinstaller not creating executable
I have been working on an script in tkinter and the EXE fails to create in the dist folder我一直在编写 tkinter 中的脚本,但 EXE 无法在 dist 文件夹中创建
I have ran this multiple ways the first is pyinstaller.exe --onefile -w myscript.py
.我已经运行了多种方式,第一种是
pyinstaller.exe --onefile -w myscript.py
。
It creates all the files and folders but in the dist folder there is no exe file.它创建所有文件和文件夹,但在 dist 文件夹中没有 exe 文件。 I then ran it as
pyinstaller.exe myscript.py
where I was able to get it to work however my buttons would quit working.然后我将它作为
pyinstaller.exe myscript.py
运行,在那里我可以让它工作,但是我的按钮会停止工作。 I have included the output below.我在下面包含了 output。 Ideally I want to use the first option.
理想情况下,我想使用第一个选项。 If you would like to see my code I can post that as well.
如果您想查看我的代码,我也可以发布。 I'm new to Python and tkinter.
我是 Python 和 tkinter 的新手。
Note: I copied the pyinstaller.exe to the folder where my script it located.注意:我将 pyinstaller.exe 复制到我的脚本所在的文件夹中。
C:\Users\test\PycharmProjects\pass>pyinstaller.exe --onefile -w pass.py
199 INFO: PyInstaller: 3.6
200 INFO: Python: 3.7.7
201 INFO: Platform: Windows-10-10.0.18362-SP0
206 INFO: wrote C:\Users\test\PycharmProjects\pass\pass.spec
210 INFO: UPX is not available.
217 INFO: Extending PYTHONPATH with paths
['C:\\Users\\test\\PycharmProjects\\pass',
'C:\\Users\\test\\PycharmProjects\\pass']
217 INFO: checking Analysis
220 INFO: Building Analysis because Analysis-00.toc is non existent
220 INFO: Initializing module dependency graph...
232 INFO: Caching module graph hooks...
244 INFO: Analyzing base_library.zip ...
3024 INFO: Processing pre-find module path hook distutils
3032 INFO: distutils: retargeting to non-venv dir 'c:\\users\\test\\appdata\\local\\programs\\python\\python37-32\\lib'
4497 INFO: Caching module dependency graph...
4693 INFO: running Analysis Analysis-00.toc
4700 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable required by c:\users\test\appdata\local\programs\python\python37-32\python.exe
5068 INFO: Analyzing C:\Users\test\PycharmProjects\pass\pass.py
5220 INFO: Processing module hooks...
5220 INFO: Loading module hook "hook-distutils.py"...
5231 INFO: Loading module hook "hook-encodings.py"...
5450 INFO: Loading module hook "hook-pydoc.py"...
5453 INFO: Loading module hook "hook-sysconfig.py"...
5458 INFO: Loading module hook "hook-xml.py"...
5750 INFO: Loading module hook "hook-_tkinter.py"...
6236 INFO: checking Tree
6236 INFO: Building Tree because Tree-00.toc is non existent
6237 INFO: Building Tree Tree-00.toc
6367 INFO: checking Tree
6368 INFO: Building Tree because Tree-01.toc is non existent
6369 INFO: Building Tree Tree-01.toc
6417 INFO: Looking for ctypes DLLs
6417 INFO: Analyzing run-time hooks ...
6421 INFO: Including run-time hook 'pyi_rth__tkinter.py'
6434 INFO: Looking for dynamic libraries
7284 INFO: Looking for eggs
7285 INFO: Using Python library c:\users\test\appdata\local\programs\python\python37-32\python37.dll
7286 INFO: Found binding redirects:
[]
7290 INFO: Warnings written to C:\Users\test\PycharmProjects\pass\build\pass\warn-pass.txt
7340 INFO: Graph cross-reference written to C:\Users\test\PycharmProjects\pass\build\pass\xref-pass.html
7397 INFO: checking PYZ
7398 INFO: Building PYZ because PYZ-00.toc is non existent
7398 INFO: Building PYZ (ZlibArchive) C:\Users\test\PycharmProjects\pass\build\pass\PYZ-00.pyz
8029 INFO: Building PYZ (ZlibArchive) C:\Users\test\PycharmProjects\pass\build\pass\PYZ-00.pyz completed successfully.
8051 INFO: checking PKG
8051 INFO: Building PKG because PKG-00.toc is non existent
8052 INFO: Building PKG (CArchive) PKG-00.pkg
10983 INFO: Building PKG (CArchive) PKG-00.pkg completed successfully.
11026 INFO: Bootloader C:\Users\test\AppData\Roaming\Python\Python37\site-packages\PyInstaller\bootloader\Windows-32bit\runw.exe
11027 INFO: checking EXE
11028 INFO: Building EXE because EXE-00.toc is non existent
11028 INFO: Building EXE from EXE-00.toc
11035 INFO: Appending archive to EXE C:\Users\test\PycharmProjects\pass\dist\pass.exe
11048 INFO: Building EXE from EXE-00.toc completed successfully.
Not really posting this as an answer, but this little script has made my life easier.并没有真正将其发布为答案,但这个小脚本让我的生活更轻松。
No need to copy pyinstaller's exe, just run the script and select your main python file to make the exe, it makes the build and dist folders where the script was ran.无需复制 pyinstaller 的 exe,只需运行脚本和 select 主 python 文件即可制作 exe,它会生成运行脚本的 build 和 dist 文件夹。
import sys, os
import tkinter as tk
from tkinter import filedialog
print(
"""
=======================================
Create a .exe file from a Python Script
=======================================
Select the Python script you want to create the .exe from:
""")
root = tk.Tk()
root.withdraw()
file = filedialog.askopenfilename(initialdir = "./", title = "Select file", filetypes = ((".py files","*.py"),
(".pyw files","*.pyw"),
(".spec","*.spec")))
if file == "." or file == None:
sys.exit()
if file.endswith('.pyw'):
#NORMAL
cmd = ('pyinstaller.exe --windowed --onefile ' + '"' + file + '"')
os.system(cmd)
elif file.endswith('.py'):
#NORMAL
cmd = ('pyinstaller.exe --onefile ' + '"' + file + '"')
os.system(cmd)
elif file.endswith('.spec'):
cmd = ('pyinstaller.exe ' + '"' + file + '"')
os.system(cmd)
os.system('pause')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.