【问题标题】:Unicode Error when running Flake8 test with TOX使用 TOX 运行 Flake8 测试时出现 Unicode 错误
【发布时间】:2017-04-13 06:17:16
【问题描述】:

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

UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 76: ordinal not in range(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

【问题讨论】:

  • 终端的echo $LANG 的输出是什么?您使用的是哪个版本的 tox?
  • @RaviKumar echo $LANG 的输出为空。我使用 Tox 2.7.0
  • 在终端写export LANG=en_US.UTF-8后可以测试吗?
  • 嘿@RaviKumar,它有效。谢谢

标签: python tox flake8


【解决方案1】:

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

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

export LANG=en_US.UTF-8

或在 tox.ini 文件中传递它

setenv = LANG=en_US.UTF-8

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-11-20
    • 2014-05-08
    • 1970-01-01
    • 2015-07-17
    • 2011-01-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多