diff options
| author | Markus Heiser <markus.heiser@darmarIT.de> | 2025-10-05 11:44:13 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-10-05 11:44:13 +0200 |
| commit | 34eb32f4185a784fdf29ef990ddb1bcd79a90fe1 (patch) | |
| tree | 5a987651b5e889b1cb8a5ab4a6b0d96fde70eac9 /searx/exceptions.py | |
| parent | 7bf65d68c2014fc99026b1c9715ddd24024208b1 (diff) | |
[fix] ModuleNotFoundError: No module named 'lxml' (#5254)
When installing SearXNG (e.g.):
pip install --use-pep517 --no-build-isolation -e .
An import exception is raised:
ModuleNotFoundError: No module named 'lxml'
The ``setup.py`` file imports ``searx``, which in turn triggers various other
imports. However, the name XPath is only needed for type checking.
Closes: https://github.com/searxng/searxng/issues/5177
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
Diffstat (limited to 'searx/exceptions.py')
| -rw-r--r-- | searx/exceptions.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/searx/exceptions.py b/searx/exceptions.py index 226b209ca..54d0b17b1 100644 --- a/searx/exceptions.py +++ b/searx/exceptions.py @@ -2,7 +2,9 @@ """Exception types raised by SearXNG modules.""" import typing as t -from lxml.etree import XPath + +if t.TYPE_CHECKING: + from lxml.etree import XPath class SearxException(Exception): @@ -40,7 +42,7 @@ class SearxEngineException(SearxException): class SearxXPathSyntaxException(SearxEngineException): """Syntax error in a XPATH""" - def __init__(self, xpath_spec: str | XPath, message: str): + def __init__(self, xpath_spec: "str | XPath", message: str): super().__init__(str(xpath_spec) + " " + message) self.message: str = message # str(xpath_spec) to deal with str and XPath instance @@ -111,7 +113,7 @@ class SearxEngineTooManyRequestsException(SearxEngineAccessDeniedException): class SearxEngineXPathException(SearxEngineResponseException): """Error while getting the result of an XPath expression""" - def __init__(self, xpath_spec: str | XPath, message: str): + def __init__(self, xpath_spec: "str | XPath", message: str): super().__init__(str(xpath_spec) + " " + message) self.message: str = message # str(xpath_spec) to deal with str and XPath instance |