以下挂起:
PS C:\Users\Fowler> pytest --version
注意:
当我按下<ctrl-c>
突破pytest的“挂起”状态时,会显示以下内容(但是每次结束时都会有些变化吗?:
Traceback (most recent call last):
File "c:\program files\python38\lib\runpy.py", line 192, in _run_module_as_main
return _run_code(code, main_globals, None,
File "c:\program files\python38\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\Fowler\AppData\Roaming\Python\Python38\Scripts\pytest.exe\__main__.py", line 7, in <module>
File "C:\Users\Fowler\AppData\Roaming\Python\Python38\site-packages\_pytest\config\__init__.py", line 72, in main
config = _prepareconfig(args, plugins)
File "C:\Users\Fowler\AppData\Roaming\Python\Python38\site-packages\_pytest\config\__init__.py", line 222, in _prepareconfig
return pluginmanager.hook.pytest_cmdline_parse(
File "C:\Users\Fowler\AppData\Roaming\Python\Python38\site-packages\pluggy\hooks.py", line 286, in __call__
return self._hookexec(self, self.get_hookimpls(), kwargs)
File "C:\Users\Fowler\AppData\Roaming\Python\Python38\site-packages\pluggy\manager.py", line 93, in _hookexec
return self._inner_hookexec(hook, methods, kwargs)
File "C:\Users\Fowler\AppData\Roaming\Python\Python38\site-packages\pluggy\manager.py", line 84, in <lambda>
self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
File "C:\Users\Fowler\AppData\Roaming\Python\Python38\site-packages\pluggy\callers.py", line 203, in _multicall
gen.send(outcome)
File "C:\Users\Fowler\AppData\Roaming\Python\Python38\site-packages\_pytest\helpconfig.py", line 89, in pytest_cmdline_parse
config = outcome.get_result()
File "C:\Users\Fowler\AppData\Roaming\Python\Python38\site-packages\pluggy\callers.py", line 80, in get_result
raise ex[1].with_traceback(ex[2])
File "C:\Users\Fowler\AppData\Roaming\Python\Python38\site-packages\pluggy\callers.py", line 187, in _multicall
res = hook_impl.function(*args)
File "C:\Users\Fowler\AppData\Roaming\Python\Python38\site-packages\_pytest\config\__init__.py", line 742, in pytest_cmdline_parse
self.parse(args)
File "C:\Users\Fowler\AppData\Roaming\Python\Python38\site-packages\_pytest\config\__init__.py", line 948, in parse
self._preparse(args, addopts=addopts)
File "C:\Users\Fowler\AppData\Roaming\Python\Python38\site-packages\_pytest\config\__init__.py", line 896, in _preparse
self.pluginmanager.load_setuptools_entrypoints("pytest11")
File "C:\Users\Fowler\AppData\Roaming\Python\Python38\site-packages\pluggy\manager.py", line 299, in load_setuptools_entrypoints
plugin = ep.load()
File "c:\program files\python38\lib\importlib\metadata.py", line 75, in load
module = import_module(match.group('module'))
File "c:\program files\python38\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "C:\Users\Fowler\AppData\Roaming\Python\Python38\site-packages\_pytest\assertion\rewrite.py", line 138, in exec_module
_write_pyc(state, co, source_stat, pyc)
File "C:\Users\Fowler\AppData\Roaming\Python\Python38\site-packages\_pytest\assertion\rewrite.py", line 274, in _write_pyc
with atomic_write(fspath(pyc), mode="wb", overwrite=True) as fp:
File "c:\program files\python38\lib\contextlib.py", line 113, in __enter__
return next(self.gen)
File "C:\Users\Fowler\AppData\Roaming\Python\Python38\site-packages\atomicwrites\__init__.py", line 156, in _open
with get_fileobject(**self._open_kwargs) as f:
File "C:\Users\Fowler\AppData\Roaming\Python\Python38\site-packages\atomicwrites\__init__.py", line 173, in get_fileobject
descriptor, name = tempfile.mkstemp(suffix=suffix, prefix=prefix,
File "c:\program files\python38\lib\tempfile.py", line 332, in mkstemp
return _mkstemp_inner(dir, prefix, suffix, flags, output_type)
File "c:\program files\python38\lib\tempfile.py", line 247, in _mkstemp_inner
file = _os.path.join(dir, pre + name + suf)
KeyboardInterrupt
下次尝试运行pytest --version
时,我碰到<ctrl-c>
时,结果为:
Traceback (most recent call last):
File "c:\program files\python38\lib\runpy.py", line 192, in _run_module_as_main
return _run_code(code, main_globals, None,
...
...
File "C:\Users\Fowler\AppData\Roaming\Python\Python38\site-packages\atomicwrites\__init__.py", line 173, in get_fileobject
descriptor, name = tempfile.mkstemp(suffix=suffix, prefix=prefix,
File "c:\program files\python38\lib\tempfile.py", line 332, in mkstemp
return _mkstemp_inner(dir, prefix, suffix, flags, output_type)
File "c:\program files\python38\lib\tempfile.py", line 248, in _mkstemp_inner
_sys.audit("tempfile.mkstemp", file)
KeyboardInterrupt
下次尝试运行pytest --version
时,我碰到<ctrl-c>
时,结果为:
Traceback (most recent call last):
File "c:\program files\python38\lib\runpy.py", line 192, in _run_module_as_main
return _run_code(code, main_globals, None,
...
...
File "C:\Users\Fowler\AppData\Roaming\Python\Python38\site-packages\atomicwrites\__init__.py", line 173, in get_fileobject
descriptor, name = tempfile.mkstemp(suffix=suffix, prefix=prefix,
File "c:\program files\python38\lib\tempfile.py", line 332, in mkstemp
return _mkstemp_inner(dir, prefix, suffix, flags, output_type)
File "c:\program files\python38\lib\tempfile.py", line 256, in _mkstemp_inner
if (_os.name == 'nt' and _os.path.isdir(dir) and
File "c:\program files\python38\lib\genericpath.py", line 42, in isdir
st = os.stat(s)
KeyboardInterrupt
下次尝试运行pytest --version
时,我碰到<ctrl-c>
时,结果为:
Traceback (most recent call last):
File "c:\program files\python38\lib\runpy.py", line 192, in _run_module_as_main
return _run_code(code, main_globals, None,
...
...
File "C:\Users\Fowler\AppData\Roaming\Python\Python38\site-packages\atomicwrites\__init__.py", line 173, in get_fileobject
descriptor, name = tempfile.mkstemp(suffix=suffix, prefix=prefix,
File "c:\program files\python38\lib\tempfile.py", line 332, in mkstemp
return _mkstemp_inner(dir, prefix, suffix, flags, output_type)
File "c:\program files\python38\lib\tempfile.py", line 250, in _mkstemp_inner
fd = _os.open(file, flags, 0o600)
KeyboardInterrupt
我不知道此输出是否有帮助,但我认为查看机器上安装python和/或pytest的所有位置可能会很有用:
PS C:\Users\Fowler> where.exe /r c:\ python
c:\Program Files\Amazon\AWSCLI\runtime\python.exe
c:\Program Files\Amazon\AWSSAMCLI\runtime\python.exe
c:\Program Files\MySQL\MySQL Workbench 8.0 CE\python.exe
c:\Program Files\Python38\python.exe
c:\Program Files\Python38\Lib\venv\scripts\nt\python.exe
c:\Users\Fowler\.vscode\extensions\lextudio.restructuredtext-116.0.0\out\python.js
c:\Users\Fowler\.vscode\extensions\teabyii.ayu-0.18.0\test\Python.py
c:\Users\Fowler\.vscode\extensions\yzane.markdown-pdf-1.4.1\node_modules\highlight.js\lib\languages\python.js
c:\Users\Fowler\AppData\Local\GitHubDesktop\app-2.2.2\resources\app\highlighter\mode\python.js
c:\Users\Fowler\AppData\Local\GitHubDesktop\app-2.2.3\resources\app\highlighter\mode\python.js
c:\Users\Fowler\AppData\Local\Google\Chrome\User Data\Default\Extensions\ngkhgikojglcgnckopipfdajaifmmnnc\4.1.34_0\python.js
c:\Users\Fowler\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu18.04onWindows_79rhkp1fndgsc\LocalState\rootfs\etc\apparmor.d\abstractions\python
c:\Users\Fowler\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu18.04onWindows_79rhkp1fndgsc\LocalState\rootfs\usr\share\bash-completion\completions\python
c:\Users\Fowler\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu18.04onWindows_79rhkp1fndgsc\LocalState\rootfs\usr\share\bash-completion\helpers\python
c:\Users\Fowler\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu18.04onWindows_79rhkp1fndgsc\LocalState\rootfs\usr\share\sosreport\sos\plugins\python.py
c:\Users\Fowler\AppData\Roaming\Python\Python38\site-packages\aniso8601\builders\python.py
c:\Users\Fowler\AppData\Roaming\Python\Python38\site-packages\_pytest\python.py
c:\Users\Fowler\Documents\vscodeProjects\playarea\.venv\Scripts\python.exe
c:\Windows\Installer\$PatchCache$\Managed\8B9C64EBE8DD53846B6846E46A14F5EE\3.7.2150\python.exe
c:\Windows\Installer\$PatchCache$\Managed\9CB0624238F6F8F469EAD6566412DD7F\3.7.2150\python.exe
PS C:\Users\Fowler> where.exe /r c:\ pytest
c:\Users\Fowler\AppData\Roaming\Python\Python38\Scripts\pytest.exe
c:\Users\Fowler\AppData\Roaming\Python\Python38\site-packages\pytest.py
最后!呵呵,万一这能说明问题,这是一张图片,显示python进程在pytest.py期间很有趣地吞噬了我的CPU。
我会非常感谢您的帮助或想法!
答案 0 :(得分:0)
已修复。
答案似乎是
不确定“根”问题是什么,但是使用python修复了所有问题。请注意,python Windows安装程序无法删除足够的python内容。
谢谢@nneonneo让我朝着正确的方向思考。
答案 1 :(得分:0)
我也有类似的问题
在我安装 pytest-cov 或 allure-pytest 后,pytest 将挂起
如果我卸载它们,一切都会恢复正常
我尝试安装不同的 pytest 版本,但没有帮助
但是,我试过你提供的方法(卸载python,删除目录),有效~,太好了!
但是,当我再次安装 allure-pytest 时,它再次失败。
最后,我发现,我无法在特权 cmd 窗口中安装软件包
如果我在特权 cmd 窗口中安装它们,它会使 pytest 挂起!
所以,如果有人遇到我遇到的问题,你可以试试我的方法。