No module named 'dolfin' ubuntu 20.04

Hi, I am trying to install fenics2019.2 in my Ubuntu 20.04 machine. I followed the following instructions:

sudo apt-get install software-properties-common
sudo add-apt-repository ppa:fenics-packages/fenics
sudo apt-get update
sudo apt-get install --no-install-recommends fenics

It got install successfully but when I try to import fenics, I am getting this error message:
ModuleNotFoundError: No module named ‘dolfin’

First check you have both python3-dolfin and python3-dolfin-real installed.

“No module named ‘dolfin’” might happen if you have a hand-built PETSc. dolfin needs to be built against a specific version of PETSc. Compare the installed petsc paths for dolfin and petsc and check they match

dpkg -L python3-dolfin-real
dpkg -L libpetsc-real3.12-dev

(replace 3.12 here with the petsc version for your system. Should be 3.12 on Ubuntu 20.04)

Check that /usr/lib/petsc is pointing at the petsc dolfin was built against (or set PETSC_DIR to specify the required PETSc installation)

Another way of putting it is, don’t do this.
i.e. don’t not install the recommended packages. They’re recommended for a reason. Use

sudo apt-get install fenics
1 Like

fenics and petsc are installed:

$dpkg -L python3-dolfin-real
/.
/usr
/usr/lib
/usr/lib/petscdir
/usr/lib/petscdir/petsc3.12
/usr/lib/petscdir/petsc3.12/x86_64-linux-gnu-real
/usr/lib/petscdir/petsc3.12/x86_64-linux-gnu-real/lib
/usr/lib/petscdir/petsc3.12/x86_64-linux-gnu-real/lib/python3
/usr/lib/petscdir/petsc3.12/x86_64-linux-gnu-real/lib/python3/dist-packages
/usr/lib/petscdir/petsc3.12/x86_64-linux-gnu-real/lib/python3/dist-packages/dolfin
/usr/lib/petscdir/petsc3.12/x86_64-linux-gnu-real/lib/python3/dist-packages/dolfin/__init__.py
/usr/lib/petscdir/petsc3.12/x86_64-linux-gnu-real/lib/python3/dist-packages/dolfin/common
/usr/lib/petscdir/petsc3.12/x86_64-linux-gnu-real/lib/python3/dist-packages/dolfin/common/__init__.py
/usr/lib/petscdir/petsc3.12/x86_64-linux-gnu-real/lib/python3/dist-packages/dolfin/common/plotting.py
/usr/lib/petscdir/petsc3.12/x86_64-linux-gnu-real/lib/python3/dist-packages/dolfin/common/timer.py
/usr/lib/petscdir/petsc3.12/x86_64-linux-gnu-real/lib/python3/dist-packages/dolfin/cpp.cpython-38-x86_64-linux-gnu.so
/usr/lib/petscdir/petsc3.12/x86_64-linux-gnu-real/lib/python3/dist-packages/dolfin/fem
/usr/lib/petscdir/petsc3.12/x86_64-linux-gnu-real/lib/python3/dist-packages/dolfin/fem/__init__.py
/usr/lib/petscdir/petsc3.12/x86_64-linux-gnu-real/lib/python3/dist-packages/dolfin/fem/adaptivesolving.py

and

$dpkg -L libpetsc-real3.12-dev
/.
/usr
/usr/lib
/usr/lib/petscdir
/usr/lib/petscdir/petsc3.12
/usr/lib/petscdir/petsc3.12/x86_64-linux-gnu-real
/usr/lib/petscdir/petsc3.12/x86_64-linux-gnu-real/include
/usr/lib/petscdir/petsc3.12/x86_64-linux-gnu-real/include/petsc.h
/usr/lib/petscdir/petsc3.12/x86_64-linux-gnu-real/include/petsc.mod
/usr/lib/petscdir/petsc3.12/x86_64-linux-gnu-real/include/petscao.h
/usr/lib/petscdir/petsc3.12/x86_64-linux-gnu-real/include/petscao.mod
/usr/lib/petscdir/petsc3.12/x86_64-linux-gnu-real/include/petscaodef.mod
/usr/lib/petscdir/petsc3.12/x86_64-linux-gnu-real/include/petscbag.h
/usr/lib/petscdir/petsc3.12/x86_64-linux-gnu-real/include/petscblaslapack.h
/usr/lib/petscdir/petsc3.12/x86_64-linux-gnu-real/include/petscblaslapack_mangle.h
/usr/lib/petscdir/petsc3.12/x86_64-linux-gnu-real/include/petscblaslapack_stdcall.h
/usr/lib/petscdir/petsc3.12/x86_64-linux-gnu-real/include/petscbt.h
/usr/lib/petscdir/petsc3.12/x86_64-linux-gnu-real/include/petsccharacteristic.h
/usr/lib/petscdir/petsc3.12/x86_64-linux-gnu-real/include/petscconf.h
/usr/lib/petscdir/petsc3.12/x86_64-linux-gnu-real/include/petscconfiginfo.h
/usr/lib/petscdir/petsc3.12/x86_64-linux-gnu-real/include/petscconvest.h

Right now I am using fencis through docker, which is not very convenient to me but it works.

Ok, what about the python3-dolfin package ?

Hi rksin8
Did you resolve your dolfin problem ?
I’m experimenting similar troubles. If in november you had solved it, I’m interested in knowing the solution.
Thanks in advance,
Marni

Apologies for the late reply,
I couldn’t able to fix this not module found error. I gave up!

is there any more update on this issue? March 2022, the same error still persists

1 Like