atom-python-black icon indicating copy to clipboard operation
atom-python-black copied to clipboard

Encoding error

Open griffinb opened this issue 7 years ago • 5 comments

Hi, I'm getting the following error when I save changes in my code:

Traceback (most recent call last):
  File "/Users/griffin/.pyenv/versions/3.6.4/bin/black", line 11, in <module>
    sys.exit(main())
  File "/Users/griffin/.pyenv/versions/3.6.4/lib/python3.6/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/Users/griffin/.pyenv/versions/3.6.4/lib/python3.6/site-packages/click/core.py", line 676, in main
    _verify_python3_env()
  File "/Users/griffin/.pyenv/versions/3.6.4/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

I visited the website mentioned in the error, but it's not obvious to me what I should do. Thought I might ask here to see if anyone else has encountered the same problem. Thanks!

griffinb avatar Nov 15 '18 14:11 griffinb

Hi, I get this same error message when using python-black. Using black from the command line works fine. Did you find a solution?

paulineribeyre avatar Nov 30 '18 20:11 paulineribeyre

Unfortunately no.

griffinb avatar Nov 30 '18 21:11 griffinb

Does the plugin work for you when not using pyenv? Have you also tried launching atom from a shell where pyenv has done all it's magic to point to the right python executable?

mikehoyio avatar Dec 18 '18 11:12 mikehoyio

I also had this issue. Here seems to be someone describing the issue: https://stackoverflow.com/questions/50308426/configure-python3-in-atom-for-non-ascii-files/50313900

A working solution for me is to type the following into the terminal ` $ export LANG=en_US.UTF-8

$ export LC_ALL=en_US.UTF-8

$ atom ` This launches atom in a context in which the python3 environment uses UTF-8 encoding, which works for me.

Sebastien32 avatar Dec 19 '18 00:12 Sebastien32

I bumped into this error with Atom 1.34 while trying to setup Black on a friend's computer, OS X system.

The export LANG=$LANG; atom trick worked.

Is there a way of doing this without having to open a terminal to launch Atom everytime?

eliasdorneles avatar Mar 06 '19 14:03 eliasdorneles