Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FileNotFoundError: No such file or directory: '[...]/assets' #2904

Closed
hiway opened this issue Mar 17, 2024 · 3 comments
Closed

FileNotFoundError: No such file or directory: '[...]/assets' #2904

hiway opened this issue Mar 17, 2024 · 3 comments

Comments

@hiway
Copy link

hiway commented Mar 17, 2024

Description

Installed flet on FreeBSD 14 under virtual environment via poetry, with Python versions 3.9 and 3.11, unable to run the hello world example.

Code example to reproduce the issue:

import flet as ft

def main(page: ft.Page):
    page.add(ft.Text(value="Hello, world!"))

ft.app(target=main)

Describe the results you received:

$ python hello.py 
Traceback (most recent call last):
  File "/home/user/.cache/pypoetry/virtualenvs/hello-nq9XZBkn-py3.9/lib/python3.9/site-packages/flet_runtime/app.py", line 186, in app_async
    fvp, pid_file = await open_flet_view_async(
  File "/home/user/.cache/pypoetry/virtualenvs/hello-nq9XZBkn-py3.9/lib/python3.9/site-packages/flet_runtime/app.py", line 321, in open_flet_view_async
    await asyncio.create_subprocess_exec(args[0], *args[1:], env=flet_env),
  File "/usr/local/lib/python3.9/asyncio/subprocess.py", line 236, in create_subprocess_exec
    transport, protocol = await loop.subprocess_exec(
  File "/usr/local/lib/python3.9/asyncio/base_events.py", line 1676, in subprocess_exec
    transport = await self._make_subprocess_transport(
  File "/usr/local/lib/python3.9/asyncio/unix_events.py", line 197, in _make_subprocess_transport
    transp = _UnixSubprocessTransport(self, protocol, args, shell,
  File "/usr/local/lib/python3.9/asyncio/base_subprocess.py", line 36, in __init__
    self._start(args=args, shell=shell, stdin=stdin, stdout=stdout,
  File "/usr/local/lib/python3.9/asyncio/unix_events.py", line 789, in _start
    self._proc = subprocess.Popen(
  File "/usr/local/lib/python3.9/subprocess.py", line 951, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/local/lib/python3.9/subprocess.py", line 1837, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '/home/user/src/flet-app/assets'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/user/src/flet-app/hello.py", line 6, in <module>
    ft.app(target=main)
  File "/home/user/.cache/pypoetry/virtualenvs/hello-nq9XZBkn-py3.9/lib/python3.9/site-packages/flet_runtime/app.py", line 70, in app
    return asyncio.run(
  File "/usr/local/lib/python3.9/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/local/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete
    return future.result()
  File "/home/user/.cache/pypoetry/virtualenvs/hello-nq9XZBkn-py3.9/lib/python3.9/site-packages/flet_runtime/app.py", line 207, in app_async
    await conn.close()
  File "/home/user/.cache/pypoetry/virtualenvs/hello-nq9XZBkn-py3.9/lib/python3.9/site-packages/flet_runtime/flet_socket_server.py", line 191, in close
    if self.__receive_loop_task:
AttributeError: 'FletSocketServer' object has no attribute '_FletSocketServer__receive_loop_task'

Describe the results you expected:

I expected the hello world example to run.

Additional information you deem important (e.g. issue happens only occasionally):

Creating the "assets" directory that Flet is expecting then makes it fail with

PermissionError: [Errno 13] Permission denied: '/home/user/src/flet-app/assets'

Flet version (pip show flet):

Name: flet
Version: 0.21.1
Summary: Flet for Python - easily build interactive multi-platform apps in Python
Home-page: 
Author: Appveyor Systems Inc.
Author-email: [email protected]
License: Apache-2.0
Location: /home/user/.cache/pypoetry/virtualenvs/hello-nq9XZBkn-py3.9/lib/python3.9/site-packages
Requires: cookiecutter, fastapi, flet-runtime, packaging, qrcode, uvicorn, watchdog
Required-by: hello

Give your requirements.txt file (don't pip freeze, instead give direct packages):

[tool.poetry.dependencies]
python = "^3.9"
flet = "^0.21.1"

Operating system:

FreeBSD 14.0

Additional environment details:

Using poetry to manage virtual environment.

@hiway hiway changed the title FileNotFoundError: [Errno 2] No such file or directory: '[...]/assets' FileNotFoundError: No such file or directory: '[...]/assets' Mar 17, 2024
@Klu1d
Copy link

Klu1d commented Mar 18, 2024

I'm encountering the same error when running any flet code on my Linux Debian system. I tried it on Windows, and everything works fine.

DeprecationWarning: The python_jwt module is deprecated
  import python_jwt as jwt
Traceback (most recent call last):
  File "/home/mark/Разработка/Chesu.news/.venv/lib/python3.11/site-packages/flet_runtime/app.py", line 199, in app_async
    on_app_startup(conn.page_url)
  File "/home/mark/Разработка/Chesu.news/.venv/lib/python3.11/site-packages/flet_runtime/app.py", line 131, in on_app_startup
    print(url_prefix, page_url)
BrokenPipeError: [Errno 32] Broken pipe

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/mark/Разработка/Chesu.news/main.py", line 49, in <module>
    ft.app(target=main, assets_dir='assets')
  File "/home/mark/Разработка/Chesu.news/.venv/lib/python3.11/site-packages/flet_runtime/app.py", line 70, in app
    return asyncio.run(
           ^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/home/mark/Разработка/Chesu.news/.venv/lib/python3.11/site-packages/flet_runtime/app.py", line 207, in app_async
    await conn.close()
  File "/home/mark/Разработка/Chesu.news/.venv/lib/python3.11/site-packages/flet_runtime/flet_socket_server.py", line 191, in close
    if self.__receive_loop_task:
       ^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'FletSocketServer' object has no attribute '_FletSocketServer__receive_loop_task'. Did you mean: '_FletSocketServer__receive_loop'?
^C

@ndonkoHenri
Copy link
Contributor

ndonkoHenri commented Mar 18, 2024

Duplicate of #2781
The fix for the FletSocketServer is present only in the latest pre-release for now:

pip install flet --pre

@ndonkoHenri ndonkoHenri added the duplicate This issue or pull request already exists label Mar 18, 2024
@ndonkoHenri
Copy link
Contributor

ndonkoHenri commented Mar 18, 2024

Oh, sorry, forgot to closely look at the first comment with the assets error.

Can you try this @hiway: https://stackoverflow.com/a/76352754

@ndonkoHenri ndonkoHenri reopened this Mar 18, 2024
@ndonkoHenri ndonkoHenri removed the duplicate This issue or pull request already exists label Mar 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants