运行Tox时如何修复“ envreport”中的“ UnicodeDecodeError”?

时间:2019-08-25 19:50:19

标签: python python-3.x tox

我想使用tox来自动测试我的python包。截至目前,仅在本地。运行Tox时,测试通过,但随后引发UnicodeDecodeError。 tox --version是3.13.2。

错误消息(下面是完整回溯):

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe4 in position 70: invalid continuation byte

在运行tox时测试成功,这可以通过-vvvvvv看到,我期望如此。这些功能什么都不做,目前只是一个虚拟对象(使用cookiecutter-pypackage自动创建)。我将envlist中的项目减少为py37。 Anaconda在我的PATH变量中,并且未安装常规python。我尝试通过编写.bat(我使用的是Windows)来使用不同的python版本,就像在正式的tox文档上一样。这与py37相同。测试通过,并引发以下情况。

tox documentation中找不到与UnicodeDecodeErrors有关的任何内容。

powershell或我的命令行都无法按照this帖子中的建议执行export LANG=en_US.UTF-8。在setenv = LANG=en_US.UTF-8中设置tox.ini也没有任何改变。

下面的回溯适用于py37环境,该环境在将skipdist = true添加到tox.ini时被调用。忽略该错误仍将返回完全相同的错误,并且回溯几乎相同。

codecy.py文件引发了错误。在Traceback中向上移动并查看每个文件并没有帮助我,因为我无法找到哪个文件被编码或其他什么可以帮助。如果没有成功创建virtualenv来发布整个控制台输出,则可能会有帮助。摘要中的envreport上将引发错误。如果重要,则不会安装tox-envreport。测试sdist时,它位于GLOB sdist-make:部分。

py37 finish: finishvenv  after 0.02 seconds
py37 start: envreport
setting PATH=C:\Users\cosmo\OneDrive - Universität zu Köln\package\.tox\py37\Scripts;C:\Users\cosmo\Anaconda3;C:\Users\cosmo\Anaconda3\Library\mingw-w64\bin;C:\Users\cosmo\Anaconda3\Library\usr\bin;C:\Users\cosmo\Anaconda3\Library\bin;C:\Users\cosmo\Anaconda3\Scripts;C:\Users\cosmo\Anaconda3\bin;C:\Users\cosmo\Anaconda3\condabin;C:\ProgramData\DockerDesktop\version-bin;C:\Program Files\Docker\Docker\Resources\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\WINDOWS\System32\OpenSSH;C:\Program Files\Git\cmd;C:\Program Files\MATLAB\R2019a\bin;C:\Program Files\PuTTY;C:\Program Files\MiKTeX 2.9\miktex\bin\x64;C:\Users\cosmo\AppData\Local\Microsoft\WindowsApps;C:\Users\cosmo\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\cosmo\AppData\Local\GitHubDesktop\bin;C:\Users\cosmo\Anaconda3\Scripts;C:\Users\cosmo\Anaconda3;.
[7836] C:\Users\cosmo\OneDrive - Universität zu Köln\package$ 'C:\Users\cosmo\OneDrive - Universität zu Köln\package\.tox\py37\Scripts\python.EXE' -m pip freeze >.tox\py37\log\py37-0.log
_________________________________________________________________________ summary __________________________________________________________________________
  py37: commands succeeded
  congratulations :)
Traceback (most recent call last):
  File "c:\users\cosmo\anaconda3\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\users\cosmo\anaconda3\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\cosmo\Anaconda3\Scripts\tox.exe\__main__.py", line 9, in <module>
  File "c:\users\cosmo\anaconda3\lib\site-packages\tox\session\__init__.py", line 44, in cmdline
    main(args)
  File "c:\users\cosmo\anaconda3\lib\site-packages\tox\session\__init__.py", line 68, in main
    exit_code = session.runcommand()
  File "c:\users\cosmo\anaconda3\lib\site-packages\tox\session\__init__.py", line 192, in runcommand
    return self.subcommand_test()
  File "c:\users\cosmo\anaconda3\lib\site-packages\tox\session\__init__.py", line 220, in subcommand_test
    run_sequential(self.config, self.venv_dict)
  File "c:\users\cosmo\anaconda3\lib\site-packages\tox\session\commands\run\sequential.py", line 20, in run_sequential
    runenvreport(venv, config)
  File "c:\users\cosmo\anaconda3\lib\site-packages\tox\session\commands\run\sequential.py", line 60, in runenvreport
    packages = config.pluginmanager.hook.tox_runenvreport(venv=venv, action=action)
  File "c:\users\cosmo\anaconda3\lib\site-packages\pluggy\hooks.py", line 289, in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
  File "c:\users\cosmo\anaconda3\lib\site-packages\pluggy\manager.py", line 87, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "c:\users\cosmo\anaconda3\lib\site-packages\pluggy\manager.py", line 81, in <lambda>
    firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
  File "c:\users\cosmo\anaconda3\lib\site-packages\pluggy\callers.py", line 208, in _multicall
    return outcome.get_result()
  File "c:\users\cosmo\anaconda3\lib\site-packages\pluggy\callers.py", line 80, in get_result
    raise ex[1].with_traceback(ex[2])
  File "c:\users\cosmo\anaconda3\lib\site-packages\pluggy\callers.py", line 187, in _multicall
    res = hook_impl.function(*args)
  File "c:\users\cosmo\anaconda3\lib\site-packages\tox\venv.py", line 780, in tox_runenvreport
    output = venv._pcall(args, cwd=venv.envconfig.config.toxinidir, action=action, returnout=True)
  File "c:\users\cosmo\anaconda3\lib\site-packages\tox\venv.py", line 574, in _pcall
    report_fail=not is_test_command,
  File "c:\users\cosmo\anaconda3\lib\site-packages\tox\action.py", line 107, in popen
    lines = out_path.read_text("UTF-8").split("\n")
  File "c:\users\cosmo\anaconda3\lib\site-packages\py\_path\common.py", line 165, in read_text
    return f.read()
  File "c:\users\cosmo\anaconda3\lib\codecs.py", line 322, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe4 in position 70: invalid continuation byte

我的问题:

  • 我该如何解决?
  • 可能是什么文件造成的(看似不好)?

1 个答案:

答案 0 :(得分:1)

只是一个猜测。 将您的应用程序放在以下文件夹之外:OneDrive-UniversitätzuKöln 我认为科隆的问题。

这是很好的回溯,可以感觉到错误报告。