I'm designing a website. The project structure is
project\ back_end\ __init.py__ main.py
In init.py,
from flask import Flaskdef create_app(): app = Flask(__name__) return app
In main.py
from back_end import create_appapp = create_app()@app.route("/")def home(): return "hello world"
When I hit run in VS Code, there is error ModuleNotFoundError
: No module named 'back_end'.
I type python -m back_end.main
in the command line, the code works. I also tried to rename the back_end package to b. The error still persists. Is it related to defining an environment variable? I am using Ubuntu 24.04.