我使用以下命令 pip install -U pytest,安装了 pytest,显示是正常安装了,但是 pytest --version 查看版本后,出现了报错,我的 Python 是 3.7.0 版本的,最新 pytest 是 6.2.4 版本,怀疑是版本兼容问题,又使用了 5.3.0 和 4 的版本,依然没有解决,求教下大家,有没有什么解决方法
C:\Users\chenlibao>pip install -U pytest
Requirement already up-to-date: pytest in c:\python37\lib\site-packages (6.2.4)
Requirement already satisfied, skipping upgrade: atomicwrites>=1.0; sys_platform == "win32" in c:\python37\lib\site-packages (from pytest) (1.4.0)
Requirement already satisfied, skipping upgrade: iniconfig in c:\python37\lib\site-packages (from pytest) (1.1.1)
Requirement already satisfied, skipping upgrade: packaging in c:\python37\lib\site-packages (from pytest) (20.9)
Requirement already satisfied, skipping upgrade: py>=1.8.2 in c:\python37\lib\site-packages (from pytest) (1.10.0)
Requirement already satisfied, skipping upgrade: toml in c:\python37\lib\site-packages (from pytest) (0.10.2)
Requirement already satisfied, skipping upgrade: attrs>=19.2.0 in c:\python37\lib\site-packages (from pytest) (19.2.0)
Requirement already satisfied, skipping upgrade: importlib-metadata>=0.12; python_version < "3.8" in c:\python37\lib\site-packages (from pytest) (1.3.0)
Requirement already satisfied, skipping upgrade: colorama; sys_platform == "win32" in c:\python37\lib\site-packages (from pytest) (0.4.1)
Requirement already satisfied, skipping upgrade: pluggy<1.0.0a1,>=0.12 in c:\python37\lib\site-packages (from pytest) (0.13.1)
Requirement already satisfied, skipping upgrade: pyparsing>=2.0.2 in c:\python37\lib\site-packages (from packaging->pytest) (2.4.2)
Requirement already satisfied, skipping upgrade: zipp>=0.5 in c:\python37\lib\site-packages (from importlib-metadata>=0.12; python_version < "3.8"->pytest) (0.6.0)
Requirement already satisfied, skipping upgrade: more-itertools in c:\python37\lib\site-packages (from zipp>=0.5->importlib-metadata>=0.12; python_version < "3.8"->pytest) (8.0.2)
You are using pip version 19.0.3, however version 21.1.3 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
查看版本,出现报错
C:\Users\chenlibao>pytest --version
Traceback (most recent call last):
File "c:\python37\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "c:\python37\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Python37\Scripts\pytest.exe\__main__.py", line 9, in <module>
File "c:\python37\lib\site-packages\_pytest\config\__init__.py", line 185, in console_main
code = main()
File "c:\python37\lib\site-packages\_pytest\config\__init__.py", line 143, in main
config = _prepareconfig(args, plugins)
File "c:\python37\lib\site-packages\_pytest\config\__init__.py", line 319, in _prepareconfig
pluginmanager=pluginmanager, args=args
File "c:\python37\lib\site-packages\pluggy\hooks.py", line 286, in __call__
return self._hookexec(self, self.get_hookimpls(), kwargs)
File "c:\python37\lib\site-packages\pluggy\manager.py", line 93, in _hookexec
return self._inner_hookexec(hook, methods, kwargs)
File "c:\python37\lib\site-packages\pluggy\manager.py", line 87, in <lambda>
firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
File "c:\python37\lib\site-packages\pluggy\callers.py", line 203, in _multicall
gen.send(outcome)
File "c:\python37\lib\site-packages\_pytest\helpconfig.py", line 100, in pytest_cmdline_parse
config: Config = outcome.get_result()
File "c:\python37\lib\site-packages\pluggy\callers.py", line 80, in get_result
raise ex[1].with_traceback(ex[2])
File "c:\python37\lib\site-packages\pluggy\callers.py", line 187, in _multicall
res = hook_impl.function(*args)
File "c:\python37\lib\site-packages\_pytest\config\__init__.py", line 1003, in pytest_cmdline_parse
self.parse(args)
File "c:\python37\lib\site-packages\_pytest\config\__init__.py", line 1283, in parse
self._preparse(args, addopts=addopts)
File "c:\python37\lib\site-packages\_pytest\config\__init__.py", line 1172, in _preparse
self.pluginmanager.load_setuptools_entrypoints("pytest11")
File "c:\python37\lib\site-packages\pluggy\manager.py", line 299, in load_setuptools_entrypoints
plugin = ep.load()
File "c:\python37\lib\site-packages\importlib_metadata\__init__.py", line 94, in load
module = import_module(match.group('module'))
File "c:\python37\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "c:\python37\lib\site-packages\_pytest\assertion\rewrite.py", line 170, in exec_module
exec(co, module.__dict__)
File "c:\python37\lib\site-packages\celery\contrib\pytest.py", line 6, in <module>
from .testing import worker
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "c:\python37\lib\site-packages\_pytest\assertion\rewrite.py", line 170, in exec_module
exec(co, module.__dict__)
File "c:\python37\lib\site-packages\celery\contrib\testing\worker.py", line 6, in <module>
from celery import worker
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "c:\python37\lib\site-packages\_pytest\assertion\rewrite.py", line 170, in exec_module
exec(co, module.__dict__)
File "c:\python37\lib\site-packages\celery\worker\__init__.py", line 3, in <module>
from .worker import WorkController
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "c:\python37\lib\site-packages\_pytest\assertion\rewrite.py", line 161, in exec_module
source_stat, co = _rewrite_test(fn, self.config)
File "c:\python37\lib\site-packages\_pytest\assertion\rewrite.py", line 354, in _rewrite_test
tree = ast.parse(source, filename=fn_)
File "c:\python37\lib\ast.py", line 35, in parse
return compile(source, filename, mode, PyCF_ONLY_AST)
File "c:\python37\lib\site-packages\celery\worker\worker.py", line 241
self._conninfo.transport.implements.async and
^
SyntaxError: invalid syntax