Installing dolphinx on Ubuntu 22.04

After running:
sudo apt update
sudo apt upgrade
sudo add-apt-repository ppa:fenics-packages/fenics
sudo apt update
sudo apt install fenicsx

pip install fenics (which does go through without problems)

and also after trying:
python -c ‘import fenics’

prusso@LeopardDragon:~$ python -c ‘import fenics’
Traceback (most recent call last):
File “”, line 1, in
File “/usr/lib/python3/dist-packages/fenics/init.py”, line 7, in
from dolfin import *
File “/usr/lib/petsc/lib/python3/dist-packages/dolfin/init.py”, line 144, in
from .fem.assembling import (assemble, assemble_system, assemble_multimesh, assemble_mixed,
File “/usr/lib/petsc/lib/python3/dist-packages/dolfin/fem/assembling.py”, line 38, in
from ufl.form import sub_forms_by_domain
ImportError: cannot import name ‘sub_forms_by_domain’ from ‘ufl.form’ (/home/prusso/.local/lib/python3.10/site-packages/ufl/form.py)

What might be the problem here for a native installation of Ubuntu 22.04 installed directly to the hardware I have?

Note that fenicsx is not fenics. fenicsx refers to dolfinx, the next generation implementation of FEniCS. It is the right one to install. fenics refers to dolfin, the older implementation. New projects should start using dolfinx.

pip generally is not the right tool to use to manage packages on an Ubuntu system since it does not carefully track the version dependencies of libraries.

But you don’t want fenics anyway. pip uninstall it, and test python3 -c "import dolfinx", not fenics.

If you decide you do want the legacy version of dolfin after all, then what you want is sudo apt install fenics, not pip install.

1 Like

OK. Fair enough that now I am knowing that much so I have two screenshots to share it of why then I might be getting a ModuleNotFound error still though I did make an effort to try to load dolphinx and also with fenics:

Screenshot from 2023-06-12 16-36-24

so after setting up docker in vs code with add new files for docker and also using the commands shown it for docker at the github site recommended so far I have these about an error dialog box and also a modulenotfounderror still left to work through for Ubuntu 22.04 vs code that is natively installed on some hardware… the dockers do seem to be found it and there is some type of pulling action going upon running a script without debugging…

So I am using the docker extension of vs code to try to get the dependancies to come in still…

You’ve got direct interference from using pip install. Delete any fenics components in .local

rm -rf /home/prusso/.local/lib/python3.10/site-packages/ufl/

et cetera…