Flask RuntimeError: Click will abort further execution because Python 3 was configured to use ASCII as encoding for the environment.

So you’ve created your virtual environments, created your Flask directory structure and now are ready to run flask:

(shiny_new_flask_app) MyComputer:shiny_new_flask_app me$ flask run
Traceback (most recent call last):
  File "/Users/me/.virtualenvs/shiny_new_flask_app/bin/flask", line 11, in 
  File "/Users/me/.virtualenvs/shiny_new_flask_app/lib/python3.6/site-packages/flask/cli.py", line 513, in main
    cli.main(args=args, prog_name=name)
  File "/Users/me/.virtualenvs/shiny_new_flask_app/lib/python3.6/site-packages/flask/cli.py", line 380, in main
    return AppGroup.main(self, *args, **kwargs)
  File "/Users/me/.virtualenvs/shiny_new_flask_app/lib/python3.6/site-packages/click/core.py", line 676, in main
  File "/Users/me/.virtualenvs/shiny_new_flask_app/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


All is not lost – just need to add a couple of locale-based environment variables. Take a look at the path to your virtual environment bin directory (in this case: /Users/me/.virtualenvs/shiny_new_flask_app/bin).

We need to add two environment variables to /Users/me/.virtualenvs/shiny_new_flask_app/bin/activate:

Using your favorite editor (mine is Sublime 3) add the appropriate locale and language config to the end of the file:

# Set project specific environment variables
export LC_ALL=en_US.utf-8
export LANG=en_US.utf-8

Then scroll up to the end of the deactivate() function.

    unset VIRTUAL_ENV
    if [ ! "$1" = "nondestructive" ] ; then
    # Self destruct!
        unset -f deactivate

Go ahead and add the following immediately prior to the closing brace:

    # Unset project specific environment variables
    unset LC_ALL
    unset LANG

Now go ahead and deactivate/reactivate your virtual environment and you should be good to go. If you need to add additional environment variables, this is a good place to add them.

Jeff Jones

  • New Jersey

Subscribe to Out Of My Head

Stay up to date! Get all the latest & greatest posts delivered straight to your inbox.