51Testing软件测试论坛

标题: 求教:pytest 安装后,查看 pytest --version 报错 [打印本页]

作者: 测试积点老人    时间: 2021-7-13 13:44
标题: 求教:pytest 安装后,查看 pytest --version 报错
我使用以下命令 pip install -U pytest,安装了 pytest,显示是正常安装了,但是 pytest --version 查看版本后,出现了报错,我的 Python 是 3.7.0 版本的,最新 pytest 是 6.2.4 版本,怀疑是版本兼容问题,又使用了 5.3.0 和 4 的版本,依然没有解决,求教下大家,有没有什么解决方法
  1. C:\Users\chenlibao>pip install -U pytest
  2. Requirement already up-to-date: pytest in c:\python37\lib\site-packages (6.2.4)
  3. Requirement already satisfied, skipping upgrade: atomicwrites>=1.0; sys_platform == "win32" in c:\python37\lib\site-packages (from pytest) (1.4.0)
  4. Requirement already satisfied, skipping upgrade: iniconfig in c:\python37\lib\site-packages (from pytest) (1.1.1)
  5. Requirement already satisfied, skipping upgrade: packaging in c:\python37\lib\site-packages (from pytest) (20.9)
  6. Requirement already satisfied, skipping upgrade: py>=1.8.2 in c:\python37\lib\site-packages (from pytest) (1.10.0)
  7. Requirement already satisfied, skipping upgrade: toml in c:\python37\lib\site-packages (from pytest) (0.10.2)
  8. Requirement already satisfied, skipping upgrade: attrs>=19.2.0 in c:\python37\lib\site-packages (from pytest) (19.2.0)
  9. Requirement already satisfied, skipping upgrade: importlib-metadata>=0.12; python_version < "3.8" in c:\python37\lib\site-packages (from pytest) (1.3.0)
  10. Requirement already satisfied, skipping upgrade: colorama; sys_platform == "win32" in c:\python37\lib\site-packages (from pytest) (0.4.1)
  11. Requirement already satisfied, skipping upgrade: pluggy<1.0.0a1,>=0.12 in c:\python37\lib\site-packages (from pytest) (0.13.1)
  12. Requirement already satisfied, skipping upgrade: pyparsing>=2.0.2 in c:\python37\lib\site-packages (from packaging->pytest) (2.4.2)
  13. 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)
  14. 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)
  15. You are using pip version 19.0.3, however version 21.1.3 is available.
  16. You should consider upgrading via the 'python -m pip install --upgrade pip' command.
复制代码
查看版本,出现报错
  1. C:\Users\chenlibao>pytest --version
  2. Traceback (most recent call last):
  3.   File "c:\python37\lib\runpy.py", line 193, in _run_module_as_main
  4.     "__main__", mod_spec)
  5.   File "c:\python37\lib\runpy.py", line 85, in _run_code
  6.     exec(code, run_globals)
  7.   File "C:\Python37\Scripts\pytest.exe\__main__.py", line 9, in <module>
  8.   File "c:\python37\lib\site-packages\_pytest\config\__init__.py", line 185, in console_main
  9.     code = main()
  10.   File "c:\python37\lib\site-packages\_pytest\config\__init__.py", line 143, in main
  11.     config = _prepareconfig(args, plugins)
  12.   File "c:\python37\lib\site-packages\_pytest\config\__init__.py", line 319, in _prepareconfig
  13.     pluginmanager=pluginmanager, args=args
  14.   File "c:\python37\lib\site-packages\pluggy\hooks.py", line 286, in __call__
  15.     return self._hookexec(self, self.get_hookimpls(), kwargs)
  16.   File "c:\python37\lib\site-packages\pluggy\manager.py", line 93, in _hookexec
  17.     return self._inner_hookexec(hook, methods, kwargs)
  18.   File "c:\python37\lib\site-packages\pluggy\manager.py", line 87, in <lambda>
  19.     firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
  20.   File "c:\python37\lib\site-packages\pluggy\callers.py", line 203, in _multicall
  21.     gen.send(outcome)
  22.   File "c:\python37\lib\site-packages\_pytest\helpconfig.py", line 100, in pytest_cmdline_parse
  23.     config: Config = outcome.get_result()
  24.   File "c:\python37\lib\site-packages\pluggy\callers.py", line 80, in get_result
  25.     raise ex[1].with_traceback(ex[2])
  26.   File "c:\python37\lib\site-packages\pluggy\callers.py", line 187, in _multicall
  27.     res = hook_impl.function(*args)
  28.   File "c:\python37\lib\site-packages\_pytest\config\__init__.py", line 1003, in pytest_cmdline_parse
  29.     self.parse(args)
  30.   File "c:\python37\lib\site-packages\_pytest\config\__init__.py", line 1283, in parse
  31.     self._preparse(args, addopts=addopts)
  32.   File "c:\python37\lib\site-packages\_pytest\config\__init__.py", line 1172, in _preparse
  33.     self.pluginmanager.load_setuptools_entrypoints("pytest11")
  34.   File "c:\python37\lib\site-packages\pluggy\manager.py", line 299, in load_setuptools_entrypoints
  35.     plugin = ep.load()
  36.   File "c:\python37\lib\site-packages\importlib_metadata\__init__.py", line 94, in load
  37.     module = import_module(match.group('module'))
  38.   File "c:\python37\lib\importlib\__init__.py", line 127, in import_module
  39.     return _bootstrap._gcd_import(name[level:], package, level)
  40.   File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  41.   File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  42.   File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  43.   File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  44.   File "c:\python37\lib\site-packages\_pytest\assertion\rewrite.py", line 170, in exec_module
  45.     exec(co, module.__dict__)
  46.   File "c:\python37\lib\site-packages\celery\contrib\pytest.py", line 6, in <module>
  47.     from .testing import worker
  48.   File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  49.   File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  50.   File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  51.   File "c:\python37\lib\site-packages\_pytest\assertion\rewrite.py", line 170, in exec_module
  52.     exec(co, module.__dict__)
  53.   File "c:\python37\lib\site-packages\celery\contrib\testing\worker.py", line 6, in <module>
  54.     from celery import worker
  55.   File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  56.   File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  57.   File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  58.   File "c:\python37\lib\site-packages\_pytest\assertion\rewrite.py", line 170, in exec_module
  59.     exec(co, module.__dict__)
  60.   File "c:\python37\lib\site-packages\celery\worker\__init__.py", line 3, in <module>
  61.     from .worker import WorkController
  62.   File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  63.   File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  64.   File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  65.   File "c:\python37\lib\site-packages\_pytest\assertion\rewrite.py", line 161, in exec_module
  66.     source_stat, co = _rewrite_test(fn, self.config)
  67.   File "c:\python37\lib\site-packages\_pytest\assertion\rewrite.py", line 354, in _rewrite_test
  68.     tree = ast.parse(source, filename=fn_)
  69.   File "c:\python37\lib\ast.py", line 35, in parse
  70.     return compile(source, filename, mode, PyCF_ONLY_AST)
  71.   File "c:\python37\lib\site-packages\celery\worker\worker.py", line 241
  72.     self._conninfo.transport.implements.async and
  73.                                             ^
  74. SyntaxError: invalid syntax
复制代码





作者: qqq911    时间: 2021-7-14 10:29
环境变量检查下
作者: bellas    时间: 2021-7-14 10:48
参考下这个链接https://testerhome.com/topics/30474
作者: 海海豚    时间: 2021-7-14 13:35
环境变量配的不对
作者: 郭小贱    时间: 2021-7-14 14:14
看着像是 celery 与 python 的版本冲突, 你把 celery 升下级试试。
作者: litingting0214    时间: 2021-7-14 16:45
重新配置下环境变量吧




欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2