My guess is there’s some interference via pip, or perhaps you’re trying to not use the default python3 provided by Ubuntu (which is python3.8). The dolfinx package only builds for the default python3 and PETSc (petsc 3.12 on Ubuntu 20.04 focal).
Check your python version with python3 --version. Check that PETSC_DIR is not set (in order to use the default petsc from /usr/lib/petsc).
Confirm your dolfinx installation:
dpkg -l *dolfinx* | cat
Confirm the module is in fact in place
ls -l /usr/lib/python3/dist-packages/dolfinx.pth /usr/lib/petscdir/petsc3.12/x86_64-linux-gnu-real/lib/python3/dist-packages/dolfinx/
If you find it’s missing, make sure that python3-dolfinx-real is installed as well as python3-dolfinx.
The output of dpkg -l *dolfinx* | cat and ls -l /usr/lib/python3/dist-packages/dolfinx.pth /usr/lib/petscdir/petsc3.12/x86_64-linux-gnu-real/lib/python3/dist-packages/dolfinx/ looks like fine.And I found the version of python is 3.9 .Should I reinstall it as 3.8 ?
Yes, you need use the default version of python3 (i.e. python3.8) to access the dolfinx packages built for ubuntu. You’ll want to work out why your python3 is pointing at python3.9 instead of python3.8.