pytest pluggy.manager.PluginValidationError: unknown hook’pytest_namespace’ error handling method

1. Background description

The colleague who tested last week said that the pytest+allure environment is no problem running on other people’s computers, but when running in her environment, an error was reported and asked for help. In fact, pytest has only heard of allure and never heard of it directly, but it can’t directly say that it won’t, 

Look at the environment pytest can be installed directly in the form of a python library: pip install pytest pytest-allure-adaptor pytest-rerunfailures pytest-html

Allure installation is also simple to download and decompress and then add the bin directory to the environment variable. Download link:


2. Problem solving

2.1 Error description

The main operating errors are as follows:

pluggy.manager.PluginValidationError: unknown hook'pytest_namespace' in plugin <module'allure.pytest_plugin' from'd:\\language\\miniconda3\\e

The complete error is as follows:

================================================== ================== test session starts =================================================================================================================================================================================================================================================================================== =======================================
platform win32 - Python 3.6.6, pytest-4.3.0, py-1.7.0, pluggy-0.8.1
rootdir: F:\PycharmProjects\pytest, inifile: pytest.ini
plugins: rerunfailures-6.0, metadata-1.8.0, html-1.20.0, allure-adaptor-1.7.10
collecting 1 item I
NTERNALERROR> Traceback (most recent call last):
INTERNALERROR> File "d:\language\miniconda3\envs\pytest\lib\site-packages\_pytest\", line 210, in wrap_session
INTERNALERROR> session.exitstatus = doit(config, session) or 0
INTERNALERROR> File "d:\language\miniconda3\envs\pytest\lib\site-packages\_pytest\", line 249, in _main
INTERNALERROR> config.hook.pytest_collection(session=session)
INTERNALERROR> File "d:\language\miniconda3\envs\pytest\lib\site-packages\pluggy\", line 284, in __call__
INTERNALERROR> return self._hookexec(self, self.get_hookimpls(), kwargs)
INTERNALERROR> File "d:\language\miniconda3\envs\pytest\lib\site-packages\pluggy\", line 68, in _hookexec
INTERNALERROR> return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR> File "d:\language\miniconda3\envs\pytest\lib\site-packages\pluggy\", line 62, in <lambda>
INTERNALERROR> firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
INTERNALERROR> File "d:\language\miniconda3\envs\pytest\lib\site-packages\pluggy\", line 208, in _multicall
INTERNALERROR> return outcome.get_result()
INTERNALERROR> File "d:\language\miniconda3\envs\pytest\lib\site-packages\pluggy\", line 80, in get_result
INTERNALERROR> raise ex[1].with_traceback(ex[2])
INTERNALERROR> File "d:\language\miniconda3\envs\pytest\lib\site-packages\pluggy\", line 187, in _multicall
INTERNALERROR> res = hook_impl.function(*args)
INTERNALERROR> File "d:\language\miniconda3\envs\pytest\lib\site-packages\_pytest\", line 259, in pytest_collection
INTERNALERROR> return session.perform_collect()
INTERNALERROR> File "d:\language\miniconda3\envs\pytest\lib\site-packages\_pytest\", line 487, in perform_collect
INTERNALERROR> self.config.pluginmanager.check_pending()
INTERNALERROR> File "d:\language\miniconda3\envs\pytest\lib\site-packages\pluggy\", line 251, in check_pending
INTERNALERROR>% (name, hookimpl.plugin),
INTERNALERROR> pluggy.manager.PluginValidationError: unknown hook'pytest_namespace' in plugin <module'allure.pytest_plugin' from'd:\\language\\miniconda3\\e


2.2 Error handling

Repeatedly re-created and configured the environment, and suddenly it ran successfully. I went back to rule out the Chinese path for the project, the Chinese path for the python environment, and the conda release. After I remembered that a page on Google said it was a version problem and I followed its recommendations. Old version installed:

Finally, it is confirmed that the new version of pytest (I am currently 4.3.0) reports an error, and it will not report an error if it is replaced with version 4.0.2:

# Uninstall the installed pytest
pip uninstall pytest
4. Installation # 0 .2 version pytest
pip install pytest== 4.0. 2

Successfully run as shown below:


Read More:

Leave a Reply

Your email address will not be published. Required fields are marked *