Flask Hello World Error
I'm new to Python and Flask so I'm sorry if I miss any details. When I launch PyCharm choose "New Project" and select Flask and using nothing but the defaults and try to run the pre-generated "app.py" I get this error:
FLASK_APP = app.py
FLASK_ENV = development
FLASK_DEBUG = 0
In folder /Users/noeltanner/Desktop/untitled
/Users/noeltanner/Desktop/untitled/venv/bin/python -m flask run
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/Users/noeltanner/Desktop/untitled/venv/lib/python3.6/site-packages/flask/__main__.py", line 15, in <module>
main(as_module=True)
File "/Users/noeltanner/Desktop/untitled/venv/lib/python3.6/site-packages/flask/cli.py", line 513, in main
cli.main(args=args, prog_name=name)
File "/Users/noeltanner/Desktop/untitled/venv/lib/python3.6/site-packages/flask/cli.py", line 380, in main
return AppGroup.main(self, *args, **kwargs)
File "/Users/noeltanner/Desktop/untitled/venv/lib/python3.6/site-packages/click/core.py", line 676, in main
_verify_python3_env()
File "/Users/noeltanner/Desktop/untitled/venv/lib/python3.6/site-packages/click/_unicodefun.py", line 118, in _verify_python3_env
'for mitigation steps.' + extra)
RuntimeError: Click will abort further execution because Python 3 was configured to use ASCII as encoding for the environment. Consult http://click.pocoo.org/python3/for mitigation steps.
This system lists a couple of UTF-8 supporting locales that
you can pick from. The following suitable locales where
discovered: af_ZA.UTF-8, am_ET.UTF-8, be_BY.UTF-8, bg_BG.UTF-8, ca_ES.UTF-8, cs_CZ.UTF-8, da_DK.UTF-8, de_AT.UTF-8, de_CH.UTF-8, de_DE.UTF-8, el_GR.UTF-8, en_AU.UTF-8, en_CA.UTF-8, en_GB.UTF-8, en_IE.UTF-8, en_NZ.UTF-8, en_US.UTF-8, es_ES.UTF-8, et_EE.UTF-8, eu_ES.UTF-8, fi_FI.UTF-8, fr_BE.UTF-8, fr_CA.UTF-8, fr_CH.UTF-8, fr_FR.UTF-8, he_IL.UTF-8, hr_HR.UTF-8, hu_HU.UTF-8, hy_AM.UTF-8, is_IS.UTF-8, it_CH.UTF-8, it_IT.UTF-8, ja_JP.UTF-8, kk_KZ.UTF-8, ko_KR.UTF-8, lt_LT.UTF-8, nl_BE.UTF-8, nl_NL.UTF-8, no_NO.UTF-8, pl_PL.UTF-8, pt_BR.UTF-8, pt_PT.UTF-8, ro_RO.UTF-8, ru_RU.UTF-8, sk_SK.UTF-8, sl_SI.UTF-8, sr_YU.UTF-8, sv_SE.UTF-8, tr_TR.UTF-8, uk_UA.UTF-8, zh_CN.UTF-8, zh_HK.UTF-8, zh_TW.UTF-8
Process finished with exit code 1
I have no idea what I did wrong. I'm on OSX 10.13.4 running PyCharm Professional 2018.1
Any help would be great!
请先登录再写评论。
Hi Noeltanner! Do you run the flask server from the built-in terminal or with specific Run Configuration? Could you please provide locale command output?
I think I may have figured out the issue. If I right click app.py ch choose "Run 'Flask (app.py)' I get the error. But if I right click and choose "run file in console" everything runs totally fine. Sorry, still learning Python and Flask!
I am getting the same error when I create a Flask run configuration. I can run the same flask command from the console and it works fine
#locale
LANG=
LC_COLLATE="C"
LC_CTYPE="en_US.UTF-8"
LC_MESSAGES="C"
LC_MONETARY="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_ALL=
look at the link in the error, as it has additional information
http://click.pocoo.org/5/python3/
adding LC_CTYPE="en_US.UTF-8" to the environment in the run config seems to resolve it