简体   繁体   English

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

[英]How to fix 'UnicodeDecodeError' in 'envreport' when running tox?

I want to use tox to automate testing of my python package. 我想使用tox来自动测试我的python包。 As of now, just locally. 截至目前,仅在本地。 When running tox, the test passes, but then a UnicodeDecodeError is thrown. 运行Tox时,测试通过,但随后引发UnicodeDecodeError。 tox --version is 3.13.2. tox --version是3.13.2。

The error message (full traceback below): 错误消息(下面是完整的回溯):

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

The tests succeed when running tox , which is visualize with -vvvvvv , which I expect. 当运行tox ,测试成功,这是我期望的-vvvvvv可视化。 The functions do not do anything and are just a dummy at the moment (Automatically created using the cookiecutter-pypackage). 这些功能什么都不做,目前只是一个虚拟对象(使用cookiecutter-pypackage自动创建)。 I reduced the items in the envlist to just py37. 我将envlist中的项目减少为py37。 Anaconda is in my PATH variable and no regular python is installed. Anaconda在我的PATH变量中,没有安装常规的python。 I tried using different python versions by writing a .bat (i am using Windows) like on the official tox documentation. 我尝试通过编写.bat(我使用的是Windows)来使用不同的python版本,就像在正式的tox文档上一样。 This works identically to the py37. 这与py37相同。 Test pass and the following is thrown. 测试通过,并引发以下情况。

I could not find anything in the tox documentation regarding UnicodeDecodeErrors . 我在tox文档中找不到有关UnicodeDecodeErrors任何内容。

Neither powershell or my commandline can execute export LANG=en_US.UTF-8 as suggested in this post. 无论是PowerShell的或命令行我可以执行export LANG=en_US.UTF-8作为建议这个职位。 Setting setenv = LANG=en_US.UTF-8 in the tox.ini also did not change anything. tox.ini设置setenv = LANG=en_US.UTF-8也没有任何改变。

The Traceback below is for the py37 environment, which gets called when adding skipdist = true to tox.ini . 下面的Traceback适用于py37环境,该环境在将skipdist = true添加到tox.ini时被调用。 Leaving that out will still return the exact same error, with an almost identical traceback. 忽略该错误仍将返回完全相同的错误,并且回溯几乎相同。

The error is thrown from codecy.py file. 该错误从codecy.py文件抛出。 Moving up in the Traceback and looking into each file didn't help me, as i could not find out, which file gets encoded or anything else, which could help. 在Traceback中向上移动并查看每个文件并没有帮助我,因为我无法找到哪个文件被编码或其他什么可以帮助。 Without posting the whole console output with the successful virtualenv creation, something could help. 如果没有成功创建virtualenv来发布整个控制台输出,则可能会有帮助。 The Error is thrown on the envreport in the summary. 该错误会在摘要中引发在envreport上。 tox-envreport is not installed if that matters. 如果重要,则不会安装tox-envreport When the sdist gets tested, it is in the GLOB sdist-make: section. 测试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

My question: 我的问题:

  • How can i fix this? 我怎样才能解决这个问题?
  • What file may be the reason for this (seemingly bad enconding)? 哪个文件可能是造成这种情况的原因(看似不好)?

Just a guess. 只是一个猜测。 Place your application outside this folder: OneDrive - Universität zu Köln The problem in Köln I think. 将您的应用程序放在此文件夹之外:OneDrive-UniversitätzuKöln我认为是Köln中的问题。

This is good traceback to feel tox bug report. 这是很好的回溯,可以感觉到错误报告。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM