模块“ io”没有属性“ _WindowsConsoleIO”

时间:2019-06-14 14:21:02

标签: python python-3.x windows unit-testing installation

我正在尝试让pytest在Windows PC上运行。它在一台机器上运行正常,但是即使我刚尝试pytest.exe --version,另一台机器也出现错误。可以运行的计算机是Windows 10商业版,但是这是Windows 10家庭版(x64)。它安装了多个版本的Python,但我尝试在3.6和3.6-32上运行它,但结果没有差异。

它是通过py -3.6 -m pip install -U pytest

安装的

运行pytest.exe --version的输出是:

PS C:\tests\unit> pytest.exe --version
Traceback (most recent call last):
  File "c:\users\pyuser\appdata\local\programs\python\python36\lib\runpy.py", line 184, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\users\pyuser\appdata\local\programs\python\python36\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\pyuser\AppData\Local\Programs\Python\python36\Scripts\pytest.exe\__main__.py", line 9, in <module>
  File "c:\users\pyuser\appdata\local\programs\python\python36\lib\site-packages\_pytest\config\__init__.py", line 63, in main
    config = _prepareconfig(args, plugins)
  File "c:\users\pyuser\appdata\local\programs\python\python36\lib\site-packages\_pytest\config\__init__.py", line 207, in _prepareconfig
    pluginmanager=pluginmanager, args=args
  File "c:\users\pyuser\appdata\local\programs\python\python36\lib\site-packages\pluggy\hooks.py", line 289, in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
  File "c:\users\pyuser\appdata\local\programs\python\python36\lib\site-packages\pluggy\manager.py", line 87, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "c:\users\pyuser\appdata\local\programs\python\python36\lib\site-packages\pluggy\manager.py", line 81, in <lambda>
    firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
  File "c:\users\pyuser\appdata\local\programs\python\python36\lib\site-packages\pluggy\callers.py", line 203, in _multicall
    gen.send(outcome)
  File "c:\users\pyuser\appdata\local\programs\python\python36\lib\site-packages\_pytest\helpconfig.py", line 94, in pytest_cmdline_parse
    config = outcome.get_result()
  File "c:\users\pyuser\appdata\local\programs\python\python36\lib\site-packages\pluggy\callers.py", line 80, in get_result
    raise ex[1].with_traceback(ex[2])
  File "c:\users\pyuser\appdata\local\programs\python\python36\lib\site-packages\pluggy\callers.py", line 187, in _multicall
    res = hook_impl.function(*args)
  File "c:\users\pyuser\appdata\local\programs\python\python36\lib\site-packages\_pytest\config\__init__.py", line 687, in pytest_cmdline_parse
    self.parse(args)
  File "c:\users\pyuser\appdata\local\programs\python\python36\lib\site-packages\_pytest\config\__init__.py", line 895, in parse
    self._preparse(args, addopts=addopts)
  File "c:\users\pyuser\appdata\local\programs\python\python36\lib\site-packages\_pytest\config\__init__.py", line 851, in _preparse
    early_config=self, args=args, parser=self._parser
  File "c:\users\pyuser\appdata\local\programs\python\python36\lib\site-packages\pluggy\hooks.py", line 289, in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
  File "c:\users\pyuser\appdata\local\programs\python\python36\lib\site-packages\pluggy\manager.py", line 87, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "c:\users\pyuser\appdata\local\programs\python\python36\lib\site-packages\pluggy\manager.py", line 81, in <lambda>
    firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
  File "c:\users\pyuser\appdata\local\programs\python\python36\lib\site-packages\pluggy\callers.py", line 208, in _multicall
    return outcome.get_result()
  File "c:\users\pyuser\appdata\local\programs\python\python36\lib\site-packages\pluggy\callers.py", line 80, in get_result
    raise ex[1].with_traceback(ex[2])
  File "c:\users\pyuser\appdata\local\programs\python\python36\lib\site-packages\pluggy\callers.py", line 182, in _multicall
    next(gen)  # first yield
  File "c:\users\pyuser\appdata\local\programs\python\python36\lib\site-packages\_pytest\capture.py", line 50, in pytest_load_initial_conftests
    _py36_windowsconsoleio_workaround(sys.stdout)
  File "c:\users\pyuser\appdata\local\programs\python\python36\lib\site-packages\_pytest\capture.py", line 820, in _py36_windowsconsoleio_workaround
    if not isinstance(raw_stdout, io._WindowsConsoleIO):
AttributeError: module 'io' has no attribute '_WindowsConsoleIO'

我在网上找不到关于此问题的任何参考资料,也不知道为什么io模块将缺少_WindowsConsoleIO属性。

0 个答案:

没有答案