Compatibilty ufl and fenics

Good morning,

I find an issue running my code. The terminal is giving me the following error message :
"
Unknown ufl object type FiniteElement
Traceback (most recent call last):
File “/mnt/c/Users/Giacomo/Documents/GitHub/pacs_new/PACS_project2/Darcy/MLDA_gwflow.py”, line 178, in
my_models.append(Model(r, field_mean, field_stdev, e, lamb_cov))
File “/mnt/c/Users/Giacomo/Documents/GitHub/pacs_new/PACS_project2/Darcy/mlda/Model.py”, line 28, in init
self.solver = GwFlowSolver(self.resolution,
File “/mnt/c/Users/Giacomo/Documents/GitHub/pacs_new/PACS_project2/Darcy/mlda/GwFlow.py”, line 33, in init
self.V = FunctionSpace(self.mesh, ‘Lagrange’, 1)
File “/usr/lib/petsc/lib/python3/dist-packages/dolfin/function/functionspace.py”, line 33, in init
self._init_convenience(*args, **kwargs)
File “/usr/lib/petsc/lib/python3/dist-packages/dolfin/function/functionspace.py”, line 100, in _init_convenience
self._init_from_ufl(mesh, element, constrained_domain=constrained_domain)
File “/usr/lib/petsc/lib/python3/dist-packages/dolfin/function/functionspace.py”, line 42, in _init_from_ufl
ufc_element, ufc_dofmap = ffc_jit(element, form_compiler_parameters=None,
File “/usr/lib/petsc/lib/python3/dist-packages/dolfin/jit/jit.py”, line 50, in mpi_jit
return local_jit(*args, **kwargs)
File “/usr/lib/petsc/lib/python3/dist-packages/dolfin/jit/jit.py”, line 100, in ffc_jit
return ffc.jit(ufl_form, parameters=p)
File “/usr/local/lib/python3.10/dist-packages/ffc/jitcompiler.py”, line 214, in jit
kind, module_name = compute_jit_prefix(ufl_object, parameters)
File “/usr/local/lib/python3.10/dist-packages/ffc/jitcompiler.py”, line 156, in compute_jit_prefix
error(“Unknown ufl object type %s” % (ufl_object.class.name,))
File “”, line 1, in
File “/usr/local/lib/python3.10/dist-packages/ufl/log.py”, line 172, in error
raise self._exception_type(self._format_raw(*message))
Exception: Unknown ufl object type FiniteElement"

I have checked and ufl seems to be installed correctly.
I can share the code if it is needed.

How should I proceed?

Thank you for your kind help

I am assuming that you are using legacy FEniCS.

Then you need to install a compatible version of ufl, see:

Furthermore, you have a mixture of packages provided by apt in /usr/lib and manual installations in /usr/local/lib

You must not have any manual installation in /usr/local, as it may destroy the one provided by apt. Uninstall every fenics related package from /usr/local, and import ufl_legacy instead of ufl.