Unable to start flask3.0 app on a minimal implementation with `invalid syntax. Perhaps you forgot a comma? (scaffold.py, line 295)`
lazydreamerbliss opened this issue · 2 comments
lazydreamerbliss commented
Simply create a minimal flask3.0 app as follow and execute it, it will fail instantly on importing from flask import Flask
:
from flask import Flask
app = Flask(__name__)
@app.route("/")
def hello_world():
return "<p>Hello, World!</p>"
app.run()
Error trace:
Traceback (most recent call last):
File "/home/lazydreamer/anaconda3/envs/test_env/lib/python3.11/runpy.py", line 198, in _run_module_as_main
return _run_code(code, main_globals, None,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/lazydreamer/anaconda3/envs/test_env/lib/python3.11/runpy.py", line 88, in _run_code
exec(code, run_globals)
File "/home/lazydreamer/.vscode-server/extensions/ms-python.debugpy-2024.4.0-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/__main__.py", line 39, in <module>
cli.main()
File "/home/lazydreamer/.vscode-server/extensions/ms-python.debugpy-2024.4.0-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", line 430, in main
run()
File "/home/lazydreamer/.vscode-server/extensions/ms-python.debugpy-2024.4.0-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", line 284, in run_file
runpy.run_path(target, run_name="__main__")
File "/home/lazydreamer/.vscode-server/extensions/ms-python.debugpy-2024.4.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 321, in run_path
return _run_module_code(code, init_globals, run_name,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/lazydreamer/.vscode-server/extensions/ms-python.debugpy-2024.4.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 135, in _run_module_code
_run_code(code, mod_globals, init_globals,
File "/home/lazydreamer/.vscode-server/extensions/ms-python.debugpy-2024.4.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 124, in _run_code
exec(code, run_globals)
File "/home/lazydreamer/Dev/TestProj/src/main.py", line 3, in <module>
from app import flask_app
File "/home/lazydreamer/Dev/TestProj/src/app.py", line 1, in <module>
from flask import Flask
File "/home/lazydreamer/anaconda3/envs/test_env/lib/python3.11/site-packages/flask/__init__.py", line 6, in <module>
from .app import Flask as Flask
File "/home/lazydreamer/anaconda3/envs/test_env/lib/python3.11/site-packages/flask/app.py", line 43, in <module>
from .sansio.app import App
File "/home/lazydreamer/anaconda3/envs/test_env/lib/python3.11/site-packages/flask/sansio/app.py", line 31, in <module>
from .scaffold import _endpoint_from_view_func
File "/home/lazydreamer/anaconda3/envs/test_env/lib/python3.11/site-packages/flask/sansio/scaffold.py", line 295
raise TypeError('Use the 'route' decorator to use the 'methods' argument.')
^^^^^^^^^^^^^^^
SyntaxError: invalid syntax. Perhaps you forgot a comma?
I am not sure what does the exception message 'Use the 'route' decorator to use the 'methods' argument.'
means as I've just upgraded to Flask3.0, but this message string is definitely not right, and I my project will not encounter any issue on Flask2.3.3.
Environment:
- Python version: 3.11.8
- Flask version: 3.0.2
- OS: Ubuntu
davidism commented
I can't reproduce that issue with the information provided. Perhaps there's something wrong with your Python environment.
HipsterSantos commented
Instead try inside virtual env and then reinstall everything after that run again if pass , it means that the problem is on you system config for python @lazydreamerbliss