Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RuntimeError: Click will abort further execution because Python 3 was configured to use ASCII #11

Open
octohedron opened this issue May 25, 2018 · 6 comments

Comments

@octohedron
Copy link

octohedron commented May 25, 2018

OS: macOs 10.13.4

Stack trace

Failed to format: unhandled error.
Command "/usr/local/Cellar/python/3.6.3/Frameworks/Python.framework/Versions/3.6/bin/python3 -m black -l 80 -" resulted in an exit code of 1.
Error: Command failed: /usr/local/Cellar/python/3.6.3/Frameworks/Python.framework/Versions/3.6/bin/python3 -m black -l 80 -
Traceback (most recent call last):
  File "/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/black.py", line 3117, in <module>
    main()
  File "/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/click/core.py", line 676, in main
    _verify_python3_env()
  File "/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/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
@sebw
Copy link

sebw commented May 26, 2018

Same problem here. Exact same stacktrace.

Black works from the command line:

$ python3 -m black -l 88 .
reformatted /Users/sw/Desktop/test.py

@joslarson
Copy link
Owner

@octohedron @sebw Sorry for the slow response guys! I messed up my notification settings and wasn't getting notified about issues on this repo.

This seems related to #9 which I published a hacky fix for a while back, but I'm not sure why it's not working for you.

TLDR: it's actually an issue with VS Code

Some workarounds are mention in #9 such as launching VS Code from your terminal instead of the dock/finder or hacking your black path to set the locale.

Also, Black formatting support just landed in the latest official Python extension, so you might want to switch to that, though I'm unsure whether it will fix your issue. My plan all along has been to deprecate this extension once the official Python extension added support for Black. Let me know if there's any reason I shouldn't go ahead with that course of action.

@joslarson
Copy link
Owner

I'm going to go ahead close this since, from what I understand, switching to the official Python extension solves the issue, and I'm going to move forward with deprecating this extension. Thanks!

@blackrobot
Copy link

@joslarson:

from what I understand, switching to the official Python extension solves the issue

Unfortunately, this does not seem to be the case for me, as I wrote in microsoft/vscode-python#1980.

Do you know what change in the official repos should have fixed this issue?

And, would you have any suggestions for working around this bug while using the official extension?

In the meantime, your extension is still working – thank you!

@joslarson joslarson reopened this Jun 18, 2018
@joslarson
Copy link
Owner

joslarson commented Jun 18, 2018

@blackrobot thanks for the info, I've reopened this (I don't know of any specific changes, no). With the official extension have you tried setting your blackPath to LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 /Users/damon/.pyenv/versions/3.6.5/bin/black?

@joslarson
Copy link
Owner

@blackrobot The only work around that I can figure out is to launch vscode from your teminal using the code command: https://code.visualstudio.com/docs/setup/mac#_launching-from-the-command-line

When you do that VS Code will inherit your system's locale settings. That's how I work anyways, so I've never run into this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants