Python 正在从_main__.py启动flask服务器
我正试图通过运行python-myu应用程序来启动flask服务器 在我的应用程序/main.py中,我有: 但是,当运行python-m my_应用程序时,我得到: 这导致:Python 正在从_main__.py启动flask服务器,python,python-3.x,flask,wsgi,Python,Python 3.x,Flask,Wsgi,我正试图通过运行python-myu应用程序来启动flask服务器 在我的应用程序/main.py中,我有: 但是,当运行python-m my_应用程序时,我得到: 这导致: * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit) * Restarting with stat Traceback (most recent call last): File "/my_app/__main__.py", line 2, in &
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
* Restarting with stat
Traceback (most recent call last):
File "/my_app/__main__.py", line 2, in <module>
from my_app.main import app
ImportError: No module named 'my_app'
显示烧瓶重新加载_umain__uu.py时发生此情况
这建议flask在不将模块添加到sys.path的情况下重新加载_umain__uu;.py。有人为此找工作吗?或者是手动将模块插入sys.path的最干净的方法。path看起来像一个循环导入问题,但是如果我将父目录添加到_umain__; py中的sys.path,它会工作。这当然意味着这不是一个循环的进口问题
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
* Restarting with stat
Traceback (most recent call last):
File "/my_app/__main__.py", line 2, in <module>
from .main import app
SystemError: Parent module '' not loaded, cannot perform relative import
from my_app.main import app
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
* Restarting with stat
Traceback (most recent call last):
File "/my_app/__main__.py", line 2, in <module>
from my_app.main import app
ImportError: No module named 'my_app'
print('1.')
from store_app.main import app
print('2.')
app.run()
print('3.')
1.
2.
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
* Restarting with stat
1.
Traceback (most recent call last):
File "/my_app/__main__.py", line 3, in <module>
from my_app.main import app
ImportError: No module named 'my_app'