flet-dev / flet

Flet enables developers to easily build realtime web, mobile and desktop apps in Python. No frontend experience required.
https://flet.dev
Apache License 2.0
11.33k stars 439 forks source link

flet run --android failing #2630

Closed dmtzs closed 1 month ago

dmtzs commented 8 months ago

Description

When I run the command flet run --android I receive the next error:

Traceback (most recent call last):
  File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\threading.py", line 1016, in _bootstrap_inner
    self.run()
  File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\threading.py", line 953, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\flet\cli\commands\run.py", line 313, in print_output
    self.print_qr_code(self.page_url, self.android)
  File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\flet\cli\commands\run.py", line 366, in print_qr_code
    qr.print_ascii(invert=True)
  File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\qrcode\main.py", line 329, in print_ascii
    out.write(codes[pos])
  File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\encodings\cp1252.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\u2588' in position 0: character maps to <undefined>

Code example to reproduce the issue:

import flet

def main(page: flet.Page) -> None:
    page.title = "NavigationBar Example"
    page.navigation_bar = flet.NavigationBar(
        destinations=[
            flet.NavigationDestination(
                icon=flet.icons.EXPLORE_OUTLINED,
                selected_icon=flet.icons.EXPLORE,
                label="Terrarium"
            ),
            flet.NavigationDestination(
                icon=flet.icons.SETTINGS_OUTLINED,
                selected_icon=flet.icons.SETTINGS,
                label="Settings"
            ),
            flet.NavigationDestination(
                icon=flet.icons.CAMERA_ALT_OUTLINED,
                selected_icon=flet.icons.CAMERA_ALT,
                label="View Camera"
            ) 
        ]
    )
    page.add(flet.Text("Temporal body"))

flet.app(target=main)

Describe the results you received:

Traceback (most recent call last):
  File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\threading.py", line 1016, in _bootstrap_inner
    self.run()
  File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\threading.py", line 953, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\flet\cli\commands\run.py", line 313, in print_output
    self.print_qr_code(self.page_url, self.android)
  File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\flet\cli\commands\run.py", line 366, in print_qr_code
    qr.print_ascii(invert=True)
  File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\qrcode\main.py", line 329, in print_ascii
    out.write(codes[pos])
  File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\encodings\cp1252.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\u2588' in position 0: character maps to <undefined>

Describe the results you expected:

I want the QR code generated by this to use it in my andriod cellphone to use the qr code with flet app

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

It happens all the time when I use the command flet run --android, for normal use cases running it like python main.py it works fine, only with flet run --android I receive errors

Flet version (pip show flet):

0.19.0

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

flet==0.19.0

Operating system:

Windows

Additional environment details: NA

lekshmanmj commented 8 months ago

can you please share the full(absolute) path to your main.py file....

dmtzs commented 8 months ago

Apparently is a bug related to git bash, if you use gitbash in windows and you try to run that command there it fails, but if you open a powershell then you're able to run the command successfully. something weird but not sure if that can be considered a bug or just that should be added to the documentation as a NOTE?

ndonkoHenri commented 1 month ago

What's the output of echo $LC_CTYPE in the bash terminal?