我已经安装了yapf
和PyYapf
软件包(https://github.com/jason-kane/PyYapf),用于Python代码格式化的高级文本。
此外,对于我的Python项目,我正在使用pipenv
。
在崇高状态下执行格式化命令时,出现以下错误
Traceback (most recent call last):
File "~/.pyenv/versions/3.6.8/bin/pipenv", line 10, in <module>
sys.exit(cli())
File "~/.pyenv/versions/3.6.8/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 764, in __call__
return self.main(*args, **kwargs)
File "~/.pyenv/versions/3.6.8/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 696, in main
_verify_python3_env()
File "~/.pyenv/versions/3.6.8/lib/python3.6/site-packages/pipenv/vendor/click/_unicodefun.py", line 124, in _verify_python3_env
' mitigation steps.' + extra
RuntimeError: Click will abort further execution because Python 3 was configured to use ASCII as encoding for the environment. Consult https://click.palletsprojects.com/en/7.x/python3/ for mitigation steps.
This system supports the C.UTF-8 locale which is recommended.
You might be able to resolve your issue by exporting the
following environment variables:
export LC_ALL=C.UTF-8
export LANG=C.UTF-8
我现在尝试使用上述两个导出,并在我的配置文件中全局设置它们(然后重新启动)。 打开终端并检查它们是否可用:
$printenv | grep "C.UTF-8"
LC_ALL=C.UTF-8
LANG=C.UTF-8
但是,崇高的文本仍然给出原始错误。看一下包的来源,就在PyYapf.py
包中像这样读取环境:
self.popen_env = os.environ.copy()
在打印self.popen_env
的内容时,LANG
和LC_ALL
似乎没有设置为C.UTF-8
或未设置为// Listen for messages
chrome.runtime.onMessage.addListener(function (msg, sender, sendResponse) {
// If the received message has the expected format...
if (msg.text === 'report_back') {
sendResponse(document);
}
});
的值。
崇高的文字从哪里得到envs?
答案 0 :(得分:4)
快速解决方法:
$ cd ~/.config/sublime-text-3/Packages
$ mkdir -p Default
$ echo 'import os; os.environ["LC_ALL"] = os.environ["LANG"] = "C.UTF-8"' > Default/echo.py
好吧,看在上帝的份上,请不要尝试这种讨厌的技巧。请花一些时间正确设置您的语言环境,否则将来您可能会遇到更多的语言环境问题。
对于Linux Mint和其他Debian变体,只需运行$ sudo dpkg-reconfigure locales
,然后在列表中勾选en_US.UTF-8
(或您喜欢的任何其他语言环境)即可。跟随these两个posts,了解有关区域设置错误的更多详细信息。