gpt4 book ai didi

python - 使用 TOX 运行 Flake8 测试时出现 Unicode 错误

转载 作者:太空宇宙 更新时间:2023-11-03 13:11:05 25 4
gpt4 key购买 nike

我是 Tox 的新手,我想将它设置为在我的项目上运行 flake8 测试,但是当我尝试运行 tox 时,我总是收到 unicode 错误。

UnicodeDecodeError:“ascii”编解码器无法解码位置 76 中的字节 0xe2:序号不在范围内 (128)

这是我的 tox.ini 文件的一瞥:

[tox]
envlist = flake8

[testenv:flake8]
basepython = python2
skip_install = true
deps =
flake8
commands =
flake8 -v

# Flake8 Configuration
[flake8]
# Ignore some flake8-docstrings errors
# NOTE(sigmavirus24): While we're still using flake8 2.x, this ignore line
# defaults to selecting all other errors so we do not need select=E,F,W,I,D
# Once Flake8 3.0 is released and in a good state, we can use both and it will
# work well \o/
ignore = D203, E226, E302, E41
exclude =
.tox,
.git,
__pycache__,
build,
dist,
*.pyc,
*.egg-info,
.cache,
.eggs
max-complexity = 10
import-order-style = google
application-import-names = flake8

最佳答案

Tox 读取环境变量以获取您的语言的编码信息。

您不能在终端中设置它。 (写入.bashrc文件使其永久生效)

export LANG=en_US.UTF-8

或者在tox.ini文件中传递

setenv = LANG=en_US.UTF-8

关于python - 使用 TOX 运行 Flake8 测试时出现 Unicode 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43384822/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com