flet icon indicating copy to clipboard operation
flet copied to clipboard

On building to windows/apk , app displays module not found error

Open vishnu-rvb opened this issue 1 year ago • 2 comments

Description

I have a flask server that is running on the url 'http://192.168.0.103:5000' in which i intent to send http request. during Flet run command the app runs without any issue and building for windows or android apk is also a success, but when running the built file module not found error is seen. I have tried to place requests module folder directly into the root but now same error but different module is occurring.

import flet as ft
from ast import literal_eval as str2lst
import requests
def main(page: ft.Page):
    page.title='Server client test'
    row=ft.TextField(label='Enter Row',value='')
    value=ft.TextField(label='Enter value',value='')
    btn=ft.ElevatedButton(text='update')
    page.add(row,value,btn)
    def update(e):
        r=int(row.value)
        l=str2lst(value.value)
        url = 'http://192.168.0.103:5000'
        response= requests.put(url+'/update',
                               json={'row':r,'value':l})
        page.add(ft.Text(f'{response.text}'))
    btn.on_click=update

ft.app(main)

Error on executing the built windows executable:

**Traceback (most recent call last): File "", line 40, in File "", line 229, in run_module File "", line 88, in run_code File "C:\Users\User\AppData\Local\Temp\serious_python_tempcd05a39c\main.py", line 3, in File "C:\Users\User\AppData\Local\Temp\serious_python_tempcd05a39c\requests_init.py", line 43, in ModuleNotFoundError: No module named 'urllib3' **

Describe the results you expected: Image during Flet run

Flet version (pip show flet):

Name: flet
Version: 0.19.0
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: c:\program files\python310\lib\site-packages
Requires: cookiecutter, flet-runtime, packaging, qrcode, watchdog, websocket-client, websockets

Requirements:

requests 2.31.0

Operating system:

Windows 10

vishnu-rvb avatar Feb 12 '24 17:02 vishnu-rvb

please try once just by having requests in requirements.txt

lekshmanmj avatar Feb 14 '24 11:02 lekshmanmj

i'm having the same issue while running flet build windows. I used poetry as dependency manager and it seems its not finding the dependencies installed. I've triied with erasing the version name of the dependencies in my requirements.txt and leaving just 3:

  • flet
  • python-docx
  • pytz

But I find the same issue.

sertemo avatar Mar 26 '24 20:03 sertemo

This problem still exist when I build Windows app that has additional third-party Python libraries in the source code. Using the latest version of flet to date (0.22.1).

Traceback (most recent call last):
  File "<string>", line 43, in <module>
  File "<frozen runpy>", line 229, in run_module
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\6ZGJMY~1\AppData\Local\Temp\serious_python_temp72b59bdf\main.py", line 3, in <module>
  File "C:\Users\6ZGJMY~1\AppData\Local\Temp\serious_python_temp72b59bdf\modules\tables.py", line 3, in <module>
  File "C:\Users\6ZGJMY~1\AppData\Local\Temp\serious_python_temp72b59bdf\modules\printer.py", line 1, in <module>
ModuleNotFoundError: No module named 'escpos'

tyu1996 avatar May 13 '24 07:05 tyu1996

I had a similar problem, and I solved it thanks to this comment --> Issue 2714

As it was a bit tedious, I decided to make a small tool to load dependencies to the windows builds (if you want to take a look). Flet Packages Loader

EmmanuelMMontesinos avatar May 14 '24 19:05 EmmanuelMMontesinos

I had a similar problem, and I solved it thanks to this comment --> Issue 2714

As it was a bit tedious, I decided to make a small tool to load dependencies to the windows builds (if you want to take a look). Flet Packages Loader

Good to hear that. 👍 Yesterday when I was finding out the root cause of this problem, I also noticed that the flet build did not use venv's packages/libraries to build the app. This should be fixed by telling flet build to look for local venv instead of global one.

tyu1996 avatar May 15 '24 00:05 tyu1996