Mach30 / kasm-dof-workspace

Mach 30 Distributed OSHW Framework Workspace (Kasm Image)
Other
1 stars 1 forks source link

[ImportError: cannot import name 'soft_unicode' from 'markupsafe' (/usr/local/lib/python3.8/dist-packages/markupsafe/__init__.py)] while running linkml-validate #9

Closed capsulecorplab closed 2 years ago

capsulecorplab commented 2 years ago
$ linkml-validate -s personinfo.yaml data.yaml
Traceback (most recent call last):
  File "/usr/local/bin/linkml-validate", line 5, in <module>
    from linkml.validators.jsonschemavalidator import cli
  File "/usr/local/lib/python3.8/dist-packages/linkml/validators/__init__.py", line 2, in <module>
    from linkml.validators.sparqlvalidator import SparqlDataValidator
  File "/usr/local/lib/python3.8/dist-packages/linkml/validators/sparqlvalidator.py", line 13, in <module>
    from linkml.generators.sparqlgen import SparqlGenerator
  File "/usr/local/lib/python3.8/dist-packages/linkml/generators/sparqlgen.py", line 9, in <module>
    from jinja2 import Template
  File "/usr/lib/python3/dist-packages/jinja2/__init__.py", line 33, in <module>
    from jinja2.environment import Environment, Template
  File "/usr/lib/python3/dist-packages/jinja2/environment.py", line 15, in <module>
    from jinja2 import nodes
  File "/usr/lib/python3/dist-packages/jinja2/nodes.py", line 23, in <module>
    from jinja2.utils import Markup
  File "/usr/lib/python3/dist-packages/jinja2/utils.py", line 656, in <module>
    from markupsafe import Markup, escape, soft_unicode
ImportError: cannot import name 'soft_unicode' from 'markupsafe' (/usr/local/lib/python3.8/dist-packages/markupsafe/__init__.py)
capsulecorplab commented 2 years ago

resolved as of https://github.com/Mach30/kasm-dof-workspace/commit/2e6de2bb3c9f7ecaec018ceb978880cb9e1fd98b

cse0001 commented 8 months ago

The root cause with your issue stems from a dependency management conflict between two software ecosystems. According to the error message, your 'markupsafe' was installed using 'pip' at the path /usr/local/lib/python3.8/dist-packages/markupsafe. The 'jinja2' that depends on it was installed using 'apt' at the path /usr/lib/python3/dist-packages/jinja2. The versions of the two are not compatible. In fact, there is a version of 'markupsafe' in the system that 'jinja2' correctly depends on, but the Python interpreter prioritizes the 'markupsafe' installed by 'pip', leading to this issue. There are typically two solutions to this problem: (1) Use 'pip' to uninstall markupsafe, and then reinstall it using 'apt', or uninstall 'jinja2' using 'apt' and reinstall it using 'pip'. (2) Use Python's imp module to customize the path and import the 'markupsafe' from the 'apt' path before importing 'jinja2'. An example is as follows:

import imp
path = ['/usr/lib/python3/dist-packages']
fp, pathname, description = imp.find_module('markupsafe', path)
imp.load_module("markupsafe", fp, pathname, description)

Hope my diagnosis is helpful to you! @capsulecorplab