`flet build` creates bundle but running it gives `ImportError: No module named main` error
Duplicate Check
- [X] I have searched the opened issues and there are no duplicates
Describe the bug
Traceback (most recent call last):
File "
Code sample
Code
print(error)
To reproduce
...
Expected behavior
No response
Screenshots / Videos
Captures
Operating System
Windows
Operating system details
11
Flet version
0.25
Regression
No, it isn't
Suggestions
No response
Logs
Logs
[Paste your logs here]
Additional details
No response
What do you have in pyproject.toml and what is the file structure of your project?
pyproject.toml
[project]
name = "weather-app"
version = "0.1.0"
description = ""
readme = "README.md"
requires-python = ">=3.8"
dependencies = [
"flet"
]
[tool.flet]
# org name in reverse domain name notation, e.g. "com.mycompany".
# Combined with project.name to build bundle ID for iOS and Android apps
org = "com.mycompany"
# project display name that is used as an app title on Android and iOS home screens,
# shown in window titles and about app dialogs on desktop.
product = "Weather Forcast"
# company name to display in about app dialogs
company = "Flet"
# copyright text to display in about app dialogs
copyright = "Copyright (C) 2024 by Flet"
[tool.flet.app]
path = "src"
Structure
W:\dev-mobile\dev mobile (flet)\api-app\weather-app>flet build apk
[09:17:25] Created Flutter bootstrap project from gh:flet-dev/flet-build-template with ref 0.25.0 ✅
Customized app icons and splash images ✅
[09:18:41] Generated app icons ✅
[09:18:51] Generated splash screens ✅
[09:21:48] Packaged Python app ✅
[09:30:39] Built .apk for Android ✅
Copied build to build\apk directory ✅
Successfully built your .apk for Android! 🥳 Find it in build\apk directory. 📁
I'm having the same problem. I created a basic project and built it right away, and it runs fine with flet run, but I get an error after building.
win11, 0.25.0
Commands used
mkdir flet-test
cd flet-test
flet create .
flet run
flet build windows -vv
cd flet build/windows
flet-test.exe
Error Description
Traceback (most recent call last):
File "<string>", line 47, in <module>
File "<frozen runpy>", line 222, in run_module
File "<frozen runpy>", line 142, in _get_module_details
ImportError: No module named main
I filmed a video of the process.
https://github.com/user-attachments/assets/c6033991-4dbb-4967-9206-2f8833cd2640
The terminal log is here. ps-log.txt
Also, apps written with existing FLETs are experiencing the same error after updating from 0.24.1 to 0.25.0.
Thanks for the additional details. I'm on it.
++ when i run 'flet run main.py --android' is not working too on my phone (app flet)
++ when i run 'flet run main.py --android' is not working too on my phone (app flet)
that's a different issue.
i don't know if that issuse from me or flet
So i would request you guys to notify us if any positive change
Upgrade to 0.25.1 and retry. Issue has been fixed.
okk bro let me try but also i would like to try the fullscreen mode where no system bar or navigation bar is shown but basing on the theming docs, they only set there colors. Can something like that be implemented.
still facing the same issuee and am using requirements.txt not the toml file. but still getting no module named requests
@HappyCoder256 what's your project structure?
Don't mind the .idx cause i upload them to the google idx, they have fast internet and cpu, but also they have flet 0.25.1, i have reinstalled that version more than 3 times but no postive change.
Make sure you have at least flet in requirements.txt. I've just tested this structure on Flet 0.25.1 with flet build apk -v and it worked like a charm:
Sir have asking should i specify the flet version in the requirements and also the requests version.