FEniCS / dolfinx

Next generation FEniCS problem solving environment
https://fenicsproject.org
GNU Lesser General Public License v3.0
731 stars 177 forks source link

Importing dolfinx crashing in python 3.10 #2258

Closed nightHawk406 closed 2 years ago

nightHawk406 commented 2 years ago

I have installed Fenicsx using Ubuntu PPA (Ubuntu 22.04). However if i try to import dolfinx it crashes with following Traceback

import dolfinx Traceback (most recent call last):' File "<stdin>", line 1, in <module> File "/usr/lib/petsc/lib/python3/dist-packages/dolfinx/__init__.py", line 35, in <module> from dolfinx import fem, geometry, graph, io, jit, la, log, mesh, nls, plot File "/usr/lib/petsc/lib/python3/dist-packages/dolfinx/fem/__init__.py", line 11, in <module> from dolfinx.fem import petsc File "/usr/lib/petsc/lib/python3/dist-packages/dolfinx/fem/petsc.py", line 33, in <module> from dolfinx.fem.function import Function as _Function File "/usr/lib/petsc/lib/python3/dist-packages/dolfinx/fem/function.py", line 30, in <module> class Constant(ufl.Constant): TypeError: function() argument 'code' must be code, not str

garth-wells commented 2 years ago

Any ideas @drew-parsons?

drew-parsons commented 2 years ago

I've confirmed dolfinx is importing successfully in python3.10 in a fresh installation of Ubuntu jammy (22.04), with (dolfinx 0.4) or without (dolfinx 0.3) the PPA. It's also working with the Debian (unstable) build.

It looks like a mismatch with the ufl API, which suggests to me the installation is not fully updated (doesn't have the new ufl). Make sure you're updated with

sudo apt-get update
sudo apt-get upgrade

If you've upgraded from an older Ubuntu release then some of the new libraries might be held back. In that case complete the full upgrade with

sudo apt-get dist-upgrade

(this is needed for example if you had the standard jammy build of dolfinx 0.3.0 already installed before adding the PPA to access dolfinx 0.4)

nightHawk406 commented 2 years ago

Finally fixed, the issue was with fenics package. If you have installed fenics and try to install fenicsx , dolfinx will use fenics-ufl-2019.1.0 which was causing crash.

The solution is to remove fenics-ufl-2019.1.0