我使用Python 3.6.5在MacOS 10.13.5上。使用此Black – Python code formatter扩展名并在干净的conda环境中安装黑色时,在visual studio代码中进行格式化时出现以下错误:
格式化失败:未处理的错误。 命令“/Users//.conda/envs/ContinuingEducation/bin/python -m>> black -l 88 - ”导致退出代码为1。 错误:命令失败:> /Users//.conda/envs/ContinuingEducation/bin/python -m black -l 88 - Traceback(最近一次调用最后一次): 文件> “/Users//.conda/envs/ContinuingEducation/lib/python3.6/runpy.py”,>第193行,在_run_module_as_main中 “主要”,mod_spec) 文件> “/Users//.conda/envs/ContinuingEducation/lib/python3.6/runpy.py”,>第85行,在_run_code中 exec(代码,run_globals) 文件“/Users//.conda/envs/ContinuingEducation/lib/python3.6/site-> packages / black.py”,第3458行,in 主要() 文件“/Users//.conda/envs/ContinuingEducation/lib/python3.6/site-> packages / click / core.py”,第722行,致电 return self.main(* args,** kwargs) 文件“/Users//.conda/envs/ContinuingEducation/lib/python3.6/site-> packages / click / core.py”,第676行,主要 _verify_python3_env() 在_verify_python3_env中输入文件“/Users//.conda/envs/ContinuingEducation/lib/python3.6/site-> packages / click / _unicodefun.py”,第118行 '缓解措施'。 +额外) RuntimeError:Click将中止进一步的执行,因为Python 3是>配置为使用ASCII作为环境的编码。咨询> http://click.pocoo.org/python3/for缓解措施。
该系统列出了几个支持UTF-8的语言环境 你可以选择。以下适合的语言环境 发现: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
我还在.zshrc和.bashrc文件中添加了以下行:
export LANG = en_US.UTF-8
导出LC_ALL = en_US.UTF-8