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.6k stars 454 forks source link

Flet Build windows error #2291

Closed alas82 closed 10 months ago

alas82 commented 11 months ago

i have been trying to build windows app using ( flet build windows ) but i got the following errors

PS C:\Users\Alaa_As\Downloads\pythonapps\myapp> flet build windows Creating Flutter bootstrap project...OK Customizing app icons and splash images...OK Generating app icons...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\Alaa_As\AppData\Local\Programs\Python\Python312\Scripts\flet.exe\__main__.py", line 7, in <module> File "C:\Users\Alaa_As\AppData\Local\Programs\Python\Python312\Lib\site-packages\flet\cli\cli.py", line 83, in main args.handler(args) File "C:\Users\Alaa_As\AppData\Local\Programs\Python\Python312\Lib\site-packages\flet\cli\commands\build.py", line 515, in handle icons_result = self.run( ^^^^^^^^^ File "C:\Users\Alaa_As\AppData\Local\Programs\Python\Python312\Lib\site-packages\flet\cli\commands\build.py", line 701, in run r = subprocess.run( ^^^^^^^^^^^^^^^ File "C:\Users\Alaa_As\AppData\Local\Programs\Python\Python312\Lib\subprocess.py", line 548, in run with Popen(*popenargs, **kwargs) as process: ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Alaa_As\AppData\Local\Programs\Python\Python312\Lib\subprocess.py", line 1026, in __init__ self._execute_child(args, executable, preexec_fn, close_fds, File "C:\Users\Alaa_As\AppData\Local\Programs\Python\Python312\Lib\subprocess.py", line 1538, in _execute_child hp, ht, pid, tid = _winapi.CreateProcess(executable, args, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ OSError: [WinError 193] %1 is not a valid Win32 application PS C:\Users\Alaa_As\Downloads\pythonapps\myapp>

please help me to resolve it thanks

09u2h4n commented 11 months ago

Do you have all dependencies, right? Flutter, android sdk maybe even android studio?

FeodorFitsner commented 11 months ago

Please run flet build windows -vv to get the detailed log and paste it here (with any sensitive data removed of course).

alas82 commented 11 months ago

Do you have all dependencies, right? Flutter, android sdk maybe even android studio?

yes all of them

alas82 commented 11 months ago

Please run flet build windows -vv to get the detailed log and paste it here (with any sensitive data removed of course).

PS C:\Users\Al\Downloads\pythonapps\myapp> flet build windows --v Flutter bootstrap directory: C:\Users\Al\AppData\Local\Temp\flet_flutter_build_LRBzuSZVTe Creating Flutter bootstrap project...OK Customizing app icons and splash images...Copying C:\Users\Al\Downloads\pythonapps\myapp\assets\icon.png to C:\Users\Al\AppData\Local\Temp\flet_flutter_build_LRBzuSZVTe\images OK Generating app icons...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\Al\AppData\Local\Programs\Python\Python312\Scripts\flet.exe\__main__.py", line 7, in <module> File "C:\Users\Al\AppData\Local\Programs\Python\Python312\Lib\site-packages\flet\cli\cli.py", line 83, in main args.handler(args) File "C:\Users\Al\AppData\Local\Programs\Python\Python312\Lib\site-packages\flet\cli\commands\build.py", line 515, in handle icons_result = self.run( ^^^^^^^^^ File "C:\Users\Al\AppData\Local\Programs\Python\Python312\Lib\site-packages\flet\cli\commands\build.py", line 701, in run r = subprocess.run( ^^^^^^^^^^^^^^^ File "C:\Users\Al\AppData\Local\Programs\Python\Python312\Lib\subprocess.py", line 548, in run with Popen(*popenargs, **kwargs) as process: ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Al\AppData\Local\Programs\Python\Python312\Lib\subprocess.py", line 1026, in __init__ self._execute_child(args, executable, preexec_fn, close_fds, File "C:\Users\Al\AppData\Local\Programs\Python\Python312\Lib\subprocess.py", line 1538, in _execute_child hp, ht, pid, tid = _winapi.CreateProcess(executable, args, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ OSError: [WinError 193] %1 is not a valid Win32 application

FeodorFitsner commented 11 months ago

Should be -vv, not --v.

alas82 commented 11 months ago

Should be -vv, not --v. same error

PS C:\Users\Al\Downloads\pythonapps\myapp> flet build windows -vv Flutter bootstrap directory: C:\Users\Al\AppData\Local\Temp\flet_flutter_build_izmzgvgnQn Creating Flutter bootstrap project...OK Customizing app icons and splash images...Copying C:\Users\Al\Downloads\pythonapps\myapp\assets\icon.png to C:\Users\Al\AppData\Local\Temp\flet_flutter_build_izmzgvgnQn\images OK Generating app icons...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\Al\AppData\Local\Programs\Python\Python312\Scripts\flet.exe\__main__.py", line 7, in <module> File "C:\Users\Al\AppData\Local\Programs\Python\Python312\Lib\site-packages\flet\cli\cli.py", line 83, in main args.handler(args) File "C:\Users\Al\AppData\Local\Programs\Python\Python312\Lib\site-packages\flet\cli\commands\build.py", line 515, in handle icons_result = self.run( ^^^^^^^^^ File "C:\Users\Al\AppData\Local\Programs\Python\Python312\Lib\site-packages\flet\cli\commands\build.py", line 701, in run r = subprocess.run( ^^^^^^^^^^^^^^^ File "C:\Users\Al\AppData\Local\Programs\Python\Python312\Lib\subprocess.py", line 548, in run with Popen(*popenargs, **kwargs) as process: ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Al\AppData\Local\Programs\Python\Python312\Lib\subprocess.py", line 1026, in __init__ self._execute_child(args, executable, preexec_fn, close_fds, File "C:\Users\Al\AppData\Local\Programs\Python\Python312\Lib\subprocess.py", line 1538, in _execute_child hp, ht, pid, tid = _winapi.CreateProcess(executable, args, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ OSError: [WinError 193] %1 is not a valid Win32 application

david-shu commented 11 months ago

The reason for this issue may be as follows:

shutil. which ('dart ') checks one by one whether ['dart','dart. bat ','dart. com',...] exists and is an executable file, but there are both 'dart' and 'dart. bat' files in the Flutter/bin folder, and os.access also determines' dart 'as an executable file. Therefore, shutil. which ('dart') returns the 'dart' file instead of 'dart. bat', which is truly executable.

So, just change the names of the dart and flutter files in the Flutter/bin folder.

alas82 commented 11 months ago

The reason for this issue may be as follows:

shutil. which ('dart ') checks one by one whether ['dart','dart. bat ','dart. com',...] exists and is an executable file, but there are both 'dart' and 'dart. bat' files in the Flutter/bin folder, and os.access also determines' dart 'as an executable file. Therefore, shutil. which ('dart') returns the 'dart' file instead of 'dart. bat', which is truly executable.

So, just change the names of the dart and flutter files in the Flutter/bin folder.

thanks for the hints , it worked but the size of the folder is become 177 mb is all these files are required to distribute for other computers? regards

FeodorFitsner commented 10 months ago

Closing as duplicate of https://github.com/flet-dev/flet/issues/2318

Please open another issue re: app size.