Start app error ,help

PS D:\code\AI-Web> python -m sanic ai.app
Failed to run app
Traceback (most recent call last):
File “C:\Users\hai.pyenv\pyenv-win\versions\3.8.1\lib\site-packages\sanic\cli\app.py”, line 75, in run
app = self._get_app()
File “C:\Users\hai.pyenv\pyenv-win\versions\3.8.1\lib\site-packages\sanic\cli\app.py”, line 135, in _get_app
raise ValueError(
ValueError: Module is not a Sanic app, it is a NoneType
Perhaps you meant ai.app.app?
PS D:\code\AI-Web>
pfoNVuEgbh

PS D:\code\AI-Web> sanic ai:app

PS D:\code\AI-Web> sanic ai:app
Failed to run app
Traceback (most recent call last):
File “C:\Users\hai.pyenv\pyenv-win\versions\3.8.1\lib\site-packages\sanic\cli\app.py”, line 75, in run
app = self._get_app()
File “C:\Users\hai.pyenv\pyenv-win\versions\3.8.1\lib\site-packages\sanic\cli\app.py”, line 135, in _get_app
raise ValueError(
ValueError: Module is not a Sanic app, it is a NoneType
Perhaps you meant ai:app.app?
PS D:\code\AI-Web>

PS D:\code\AI-Web> python -m sanic ai:app
Failed to run app
Traceback (most recent call last):
File “C:\Users\hai.pyenv\pyenv-win\versions\3.8.1\lib\site-packages\sanic\cli\app.py”, line 75, in run
app = self._get_app()
File “C:\Users\hai.pyenv\pyenv-win\versions\3.8.1\lib\site-packages\sanic\cli\app.py”, line 135, in _get_app
raise ValueError(
ValueError: Module is not a Sanic app, it is a NoneType
Perhaps you meant ai:app.app?
PS D:\code\AI-Web>

PS D:\code\AI-Web> python -V
Python 3.8.1
PS D:\code\AI-Web>python

import sanic
sanic.version
‘21.12.1’

Please share the contents of ai.py

import sys
import signal

from sanic import Sanic
from sanic_openapi import openapi2_blueprint

from ai.utils.GlobalHandler import GlobalHandler
from ai.utils.GlobalListener import (main_start, after_start, after_stop, before_start,
                                     before_stop, main_stop, sigint_handler)
from ai.utils.GlobalMiddleware import server_request, server_response
from ai.utils.Config import CONFIG
from ai.api import homepage

app = Sanic(CONFIG.SERVER_NAME)
# app = Sanic.get_app(CONFIG.SERVER_NAME, force_create=True)


app.update_config(config=CONFIG)


app.error_handler = GlobalHandler()


app.blueprint(homepage)


if app.config.DEBUG:
    app.blueprint(openapi2_blueprint)


app.register_listener(main_start, "main_process_start")


app.register_listener(before_start, "before_server_start")


app.register_listener(after_start, "after_server_start")


app.register_listener(before_stop, "before_server_stop")


app.register_listener(after_stop, "after_server_stop")


app.register_listener(main_stop, "main_process_stop")


app.register_middleware(server_request, attach_to="request")


app.register_middleware(server_response, attach_to="response")


signal.signal(signal.SIGINT, sigint_handler)


app.static('/', './static', name="ai-static")


app.config.HOST = '127.0.0.1'
app.config.PORT = 8080


if __name__ == '__main__':
    app.run(host=app.config.HOST, port=app.config.PORT,
            debug=app.config.DEBUG, access_log=app.config.ACCESS_LOG)
else:
    for item in sys.argv:
        if item and "=" in item:
            item_key, item_value = tuple(item.split("="))
            if item_key.lower() == "--host":
                app.config.HOST = str(item_value)
            if item_key.lower() == "--port":
                app.config.PORT = int(item_value)

I think you have a module naming issue. It looks like you have both a file called ai.py and a directory called ai that has a __init__.py. Looks like you have a collision problem.