My Flet app works on another Windows PC but not on mine. #5310
Replies: 2 comments 1 reply
-
An interesting one. It could be a security restriction given the way that Flet uses sockets for communication, especially given it works on other machines. It is hard to say definitively, but given Flet's random socket nature (it finds a random open socket) "Accept failed on a socket" looks like it could be caused by this. What version of Flet are you on?
In the issue above, you mention "executable", have you built your code into a Windows random_application.exe? If so, using Flet Build, or Flet Pack? Before starting, try disabling any antivirus software and running the app, see if that fixes it, but if not.. Try the following minimal application, while explicitly stating the port: import flet as ft
def main(page: ft.Page):
page.add(ft.Text("Hello, Flet!"))
# Run Flet app on a specific port
ft.app(target=main, port=8080) You might be able to trigger any antivirus / blocking by trying to manually bind / listen to a port: import socket
import sys
TEST_PORT = 8080 # Or some other port Flet might try. I used the same as the demo app above.
try:
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.bind(('127.0.0.1', TEST_PORT))
s.listen()
print(f"Successfully listening on 127.0.0.1:{TEST_PORT}")
print("Waiting for a connection (Ctrl+C to exit)...")
conn, addr = s.accept() # This will block until a connection
with conn:
print(f"Connected by {addr}")
except OSError as e:
print(f"Error: Could not bind/listen on port {TEST_PORT}. OS error: {e}")
sys.exit(1)
except Exception as e:
print(f"An unexpected error occurred: {e}")
sys.exit(1) Does the manual Python script work, but Flet fail? If that fails, set up a logging/logger to try and see if Flet is giving any useful clues itself. import logging
import flet as ft
import sys
LOG_FILENAME = 'flet_app.log'
LOG_LEVEL = logging.DEBUG
logging.basicConfig(
level=LOG_LEVEL,
format='%(asctime)s - %(levelname)s - %(name)s - [%(threadName)s:%(thread)d] - %(message)s (%(pathname)s:%(lineno)d)',
filename=LOG_FILENAME,
filemode='w'
)
logging.info("Logging initialized for Flet app.")
def main(page: ft.Page):
page.title = "Logging Test App"
page.add(ft.Text("Hello, Flet with logging!"))
logging.debug("Main page loaded.")
if __name__ == "__main__":
ft.app(
target=main,
logging_level=logging.DEBUG
) |
Beta Was this translation helpful? Give feedback.
-
did you find the solution to this? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I developed a Flet app in Python on my Windows 10 PC, with Visual Code and Python 3.12.7. On my PC, the app opens but keeps processing and does not show the elements, such as the buttons and textbox. I copied the same executable and ran it on 3 other computers, which do not have Python installed, and they all opened normally. Does anyone know if there is a security block or something else that could be causing this problem? For testing, I created a new app using the example from the official Flet website, and it also does not work on my PC and worked on another. See the code and the error return in the terminal below.
Terminal error
& C:/Users/filip/AppData/Local/Programs/Python/Python312/python.exe d:/Ruiz/07_AppFlet/1_App_Flet_Teste.py
Accept failed on a socket
socket: <asyncio.TransportSocket fd=900, family=2, type=1, proto=0, laddr=('127.0.0.1', 62206)>
Traceback (most recent call last):
File "C:\Users\filip\AppData\Local\Programs\Python\Python312\Lib\asyncio\proactor_events.py", line 846, in loop
conn, addr = f.result()
^^^^^^^^^^
File "C:\Users\filip\AppData\Local\Programs\Python\Python312\Lib\asyncio\windows_events.py", line 803, in _poll
value = callback(transferred, key, ov)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\filip\AppData\Local\Programs\Python\Python312\Lib\asyncio\windows_events.py", line 561, in finish_accept
return conn, conn.getpeername()
^^^^^^^^^^^^^^^^^^
OSError: [WinError 10014] O sistema detectou um endereço de ponteiro inválido ao tentar usar um argumento de ponteiro em uma chamada
Task exception was never retrieved
future: <Task finished name='Task-3' coro=<IocpProactor.accept..accept_coro() done, defined at C:\Users\filip\AppData\Local\Programs\Python\Python312\Lib\asyncio\windows_events.py:563> exception=OSError(14, 'O sistema detectou um endereço de ponteiro inválido ao tentar usar um argumento de ponteiro em uma chamada', None, 10014, None)>
Traceback (most recent call last):
File "C:\Users\filip\AppData\Local\Programs\Python\Python312\Lib\asyncio\windows_events.py", line 566, in accept_coro
await future
OSError: [WinError 10014] O sistema detectou um endereço de ponteiro inválido ao tentar usar um argumento de ponteiro em uma chamada
Beta Was this translation helpful? Give feedback.
All reactions