# Compatibilty ufl and fenics

**URL:** https://fenicsproject.discourse.group/t/compatibilty-ufl-and-fenics/13974
**Category:** General
**Created:** [March 20, 2024, 6:52am UTC](https://fenicsproject.discourse.group/t/compatibilty-ufl-and-fenics/13974 "2024-03-20T06:52:39Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![jackmoss](https://avatars.discourse-cdn.com/v4/letter/j/e47c2d/32.png) [@jackmoss](https://fenicsproject.discourse.group/u/jackmoss)
#### Post date: [March 20, 2024, 6:52am UTC](https://fenicsproject.discourse.group/t/compatibilty-ufl-and-fenics/13974/1 "2024-03-20T06:52:39Z")

</div>

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

---

<div class="post-metadata">

### Author: ![dokken](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/dokken/32/1560_2.png) [@dokken](https://fenicsproject.discourse.group/u/dokken)
#### Post date: [March 20, 2024, 6:54am UTC](https://fenicsproject.discourse.group/t/compatibilty-ufl-and-fenics/13974/2 "2024-03-20T06:54:59Z")

</div>

I am assuming that you are using legacy FEniCS.

> [@jackmoss](#):
>
> 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)

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

> [@Announcement: ufl\_legacy and legacy dolfin](https://fenicsproject.discourse.group/t/announcement-ufl-legacy-and-legacy-dolfin/11583):
>
> tl;dr: UFL is no longer compatible with legacy dolfin. A ufl\_legacy package will be created to help keep old dolfin projects computing. Depending on how you use ufl, you might need to replace import ufl with import ufl\_legacy as ufl. Challenge: UFL continues to be developed alongside dolfinx (and ffcx/basix, and firedrake). The 2023 release of UFL broke compatibility with legacy dolfin (and old ffc). The use-case requiring simultaneous installation of both dolfin and dolfinx might be, for in…

---

<div class="post-metadata">

### Author: ![francesco-ballarin](https://avatars.discourse-cdn.com/v4/letter/f/f05b48/32.png) [@francesco-ballarin](https://fenicsproject.discourse.group/u/francesco-ballarin)
#### Post date: [March 20, 2024, 8:53am UTC](https://fenicsproject.discourse.group/t/compatibilty-ufl-and-fenics/13974/3 "2024-03-20T08:53:23Z")

</div>

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.
