flet icon indicating copy to clipboard operation
flet copied to clipboard

`flet build` creates bundle but running it gives `ImportError: No module named main` error

Open OmarBelfeki opened this issue 2 years ago • 15 comments

Duplicate Check

  • [X] I have searched the opened issues and there are no duplicates

Describe the bug

Traceback (most recent call last): File "", line 47, in File "", line 222, in run_module File "", line 142, in _get_module_details ImportError: No module named main

Code sample

Code
print(error)

To reproduce

...

Expected behavior

No response

Screenshots / Videos

Captures

Screenshot_2024-11-28-23-36-20-36_92b64b2a7aa6eb3771ed6e18d0029815

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

OmarBelfeki avatar Nov 28 '24 22:11 OmarBelfeki

What do you have in pyproject.toml and what is the file structure of your project?

FeodorFitsner avatar Nov 28 '24 23:11 FeodorFitsner

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. 📁

Screenshot 2024-11-29 091419

Screenshot 2024-11-29 091455 Screenshot 2024-11-29 091512

OmarBelfeki avatar Nov 29 '24 08:11 OmarBelfeki

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.

N0Works avatar Nov 29 '24 16:11 N0Works

Thanks for the additional details. I'm on it.

FeodorFitsner avatar Nov 29 '24 17:11 FeodorFitsner

++ when i run 'flet run main.py --android' is not working too on my phone (app flet)

OmarBelfeki avatar Nov 29 '24 18:11 OmarBelfeki

++ when i run 'flet run main.py --android' is not working too on my phone (app flet)

that's a different issue.

FeodorFitsner avatar Nov 29 '24 18:11 FeodorFitsner

i don't know if that issuse from me or flet

OmarBelfeki avatar Nov 29 '24 18:11 OmarBelfeki

So i would request you guys to notify us if any positive change

HappyCoder256 avatar Dec 04 '24 19:12 HappyCoder256

Upgrade to 0.25.1 and retry. Issue has been fixed.

ndonkoHenri avatar Dec 04 '24 19:12 ndonkoHenri

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.

HappyCoder256 avatar Dec 04 '24 19:12 HappyCoder256

still facing the same issuee and am using requirements.txt not the toml file. but still getting no module named requests

HappyCoder256 avatar Dec 05 '24 20:12 HappyCoder256

@HappyCoder256 what's your project structure?

FeodorFitsner avatar Dec 05 '24 20:12 FeodorFitsner

image 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.

HappyCoder256 avatar Dec 06 '24 14:12 HappyCoder256

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:

image

FeodorFitsner avatar Dec 06 '24 18:12 FeodorFitsner

Sir have asking should i specify the flet version in the requirements and also the requests version.

HappyCoder256 avatar Dec 08 '24 11:12 HappyCoder256