I get a lot of error messages when I run the code pyinstaller --onefile --windowed --clean Todo_gui.py and an empty dist folder
Typed out below are the full error messages I get when I run the code
72007 WARNING: Execution of 'remove_all_resources' failed on attempt #1 / 20: error(110, 'EndUpdateResourceW', 'The system cannot open the device or file specified.'). Retrying in 0.05 second(s)...
Traceback (most recent call last):
File "C:\Users\käyttäjä\PycharmProjects\Todo\.venv\Lib\site-packages\win32ctypes\pywin32\pywintypes.py", line 36, in pywin32error
yield
File "C:\Users\käyttäjä\PycharmProjects\Todo\.venv\Lib\site-packages\win32ctypes\pywin32\win32api.py", line 209, in BeginUpdateResource
return _resource._BeginUpdateResource(filename, delete)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\käyttäjä\PycharmProjects\Todo\.venv\Lib\site-packages\win32ctypes\core\ctypes\_util.py", line 39, in check_null
raise make_error(function, function_name)
OSError: [WinError 2] The system cannot find the file specified.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "C:\Users\käyttäjä\PycharmProjects\Todo\.venv\Scripts\pyinstaller.exe\__main__.py", line 7, in <module>
File "C:\Users\käyttäjä\PycharmProjects\Todo\.venv\Lib\site-packages\PyInstaller\__main__.py", line 231, in _console_script_run
run()
File "C:\Users\käyttäjä\PycharmProjects\Todo\.venv\Lib\site-packages\PyInstaller\__main__.py", line 215, in run
run_build(pyi_config, spec_file, **vars(args))
File "C:\Users\käyttäjä\PycharmProjects\Todo\.venv\Lib\site-packages\PyInstaller\__main__.py", line 70, in run_build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
File "C:\Users\käyttäjä\PycharmProjects\Todo\.venv\Lib\site-packages\PyInstaller\building\build_main.py", line 1252, in main
build(specfile, distpath, workpath, clean_build)
File "C:\Users\käyttäjä\PycharmProjects\Todo\.venv\Lib\site-packages\PyInstaller\building\build_main.py", line 1192, in build
exec(code, spec_namespace)
File "C:\Users\käyttäjä\PycharmProjects\Todo\Todo_gui.spec", line 19, in <module>
exe = EXE(
^^^^
File "C:\Users\käyttäjä\PycharmProjects\Todo\.venv\Lib\site-packages\PyInstaller\building\api.py", line 658, in __init__
self.__postinit__()
File "C:\Users\käyttäjä\PycharmProjects\Todo\.venv\Lib\site-packages\PyInstaller\building\datastruct.py", line 184, in __postinit__
self.assemble()
File "C:\Users\käyttäjä\PycharmProjects\Todo\.venv\Lib\site-packages\win32ctypes\pywin32\win32api.py", line 208, in BeginUpdateResource
with _pywin32error():
^^^^^^^^^^^^^^^
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.2032.0_x64__qbz5n2kfra8p0\Lib\contextlib.py", line 158, in __exit__
self.gen.throw(value)
File "C:\Users\käyttäjä\PycharmProjects\Todo\.venv\Lib\site-packages\win32ctypes\pywin32\pywintypes.py", line 40, in pywin32error
raise error(exception.winerror, exception.function, exception.strerror)
win32ctypes.pywin32.pywintypes.error: (2, 'BeginUpdateResourceW', 'The system cannot find the file specified.')
I am currently learning python and I built a todo app GUI from a tutorial on a course and tried to turn it into a standalone executable using pyinstaller but I get different errors and it also gives me an empty dist folder. I expected to have a standalone executable app in the dist folder. Below is the code I tried in the pycharm terminal which returns the error
pyinstaller --onefile --windowed --clean Todo_gui.py
Below is the full code for the todo app GUI
import Functions
import FreeSimpleGUI as sg
import time
import os
if not os.path.exists("todo.txt"):
with open("todo.txt", "w") as file:
pass
sg.theme("GreenMono")
clock = sg.Text("", key="clock")
label = sg.Text("Type in a todo")
input_box = sg.InputText(tooltip="Enter todo", key="todo")
add_button = sg.Button("Add")
list_box = sg.Listbox(values=Functions.get_todos(), key="todos",
enable_events=True, size=[45, 10])
edit_button = sg.Button("Edit")
complete_button = sg.Button("Complete")
exit_button = sg.Button("Exit")
window = sg.Window("My todo App",
layout=[[clock],
[label],
[input_box, add_button],
[list_box, edit_button, complete_button],
[exit_button]],
font=("Times New Roman", 18))
while True:
event, values = window.read(timeout=200)
window["clock"].update(value=time.strftime("%B %D, %Y %H:%M:%S"))
match event:
case "Add":
todos = Functions.get_todos()
new_todo = values["todo"] + "\n"
todos.append(new_todo)
Functions.write_todos(todos)
window["todos"].update(values=todos)
case "Edit":
try:
todo_to_edit = values["todos"][0]
new_todo = values["todo"]
todos = Functions.get_todos()
index = todos.index(todo_to_edit)
todos[index] = new_todo
Functions.write_todos(todos)
window["todos"].update(values=todos)
except IndexError:
sg.popup("You need to select an item", font=("Times New Roman", 18))
case "Complete":
try:
todo_to_complete = values["todos"][0]
todos = Functions.get_todos()
todos.remove(todo_to_complete)
Functions.write_todos(todos)
window["todos"].update(values=todos)
window["todo"].update(value="")
except IndexError:
sg.popup("You need to select an item", font=("Times New Roman", 18))
case "Exit":
break
case "todos":
window["todo"].update(value=values["todos"][0])
case sg.WIN_CLOSED:
break
window.close()
Below is the full code for my functions.py file
FILEPATH = "todo.txt"
def get_todos(filepath=FILEPATH):
""" Read a text file and return the list of
to-do items.
"""
with open(filepath, 'r') as file_local:
todos_local = file_local.readlines()
return todos_local
def write_todos(todos_arg, filepath=FILEPATH):
""" Write the to-do items list in the text file."""
with open(filepath, 'w') as file:
file.writelines(todos_arg)
if __name__ == "__main__":
print("Hello")
print(get_todos())
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742324140a4422406.html
评论列表(0条)