Dolfinx and FEniCSx installation

OK I am going to go ahead and make a fool of myself by asking this very trivial question, hopefully you guys would forgive me :slightly_smiling_face:
I installed FEniCS by running the following commands on my Ubuntu 20.04 Focal Fossa:

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

The above commands come from this page.
I checked my installation and it works fine, I also ran the found on this page and again it works very fine.

Eventually I bumped up on this page which seems to address a whole new version of things.
For instance I tried to run the and this time I got an error saying that module dolfinx doesn't exist.
Could somebody help me out here, what am I missing?
Here are the questions that may help you understand my confusion:

  1. Is the process of installing FEniCSx different from the installation commands I pointed out above?
  2. Should dolfinx be installed separately or it comes with FEniCSx installation?
  3. The tutorial on this page claims to be an adaptation of this Tutorial but the scripts are quite different. Should I just forget this and move along with this?

Thanks a bunch

Hi Sou-Ren, it’s not a dumb question. You’ve installed fenics, which is the legacy version of FEniCS. It provides dolfin, not dolfinx. What you want (if you want dolfinx, not dolfin), is the fenicsx package.

sudo apt-get install fenicsx
1 Like

Thank you dparsons,
I just ran sudo apt install fenicsx then python3 -c "import dolfinx" (given here) and I didn’t get any error message which I believe means the installation is fine. Which I suppose means I don’t need to go through the whole docker installation of dolfinx as explained here right?

Apart from above question when I run python3 (given here) it complains as follows

 Traceback (most recent call last):
   File "", line 84, in <module>
     from dolfinx.mesh import CellType, GhostMode, locate_entities_boundary
 ImportError: cannot import name 'CellType' from 'dolfinx.mesh' (/usr/lib/petsc/lib/python3/dist-packages/dolfinx/

docker is an alternative means for getting access to the package, maintained inside a container (a virtual machine). You might use it if you don’t have sudo access to install ubuntu packages. If you have sudo access, then you don’t need docker, since you already have the package installed.

dolfinx (fenicsx) is the new version of the package. It’s been developed rapidly over the past year and is still in development. That’s why the lastest release is v0.3 not v1.0 (check that you do have 0.3.0 installed). Your error message probably means the demo doesn’t match the installed version. Likely it got updated for the latest development version and has already lost compatibility with 0.3.0. Try dolfinx/python/demo/poisson at v0.3.0 · FEniCS/dolfinx · GitHub

Thanks again dparsons
It suns smoothly :slightly_smiling_face:
Just another quick question though.
Before going through all modifications you suggested I had FEniCS installed using the following commands

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

and to get fenicsx and dolfinx I simply ran sudo apt install fenicsx meaning I only changed the last line of the above command and I got dolfinx. But what about the second line where we have ppa:fenics-packages/fenics I didn’t change fenics to fenicsx in this line and it seems not having any impact.
Why is that? any idea?

The PPA is the FEniCS repository for ubuntu packages for the latest release. It’s packages that we (I) prepare ourselves, since the official ubuntu packages don’t get updated and will be stuck at the version available at the time of the ubuntu release. The PPA address is, it provides both the old dolfin and new dolfinx versions.

You can compare the ubuntu versions available to you with apt-cache show fenics fenicsx, you’ll see older versions listed there (the official ubuntu packages).


Hi Dear @dparsons
would you please share the code for installing dolfinx (fenicsx) on Mac?
I am using anaconda

Hi @arash_goli , you can find download (installation) instructions linked from the project home page at

1 Like

Thanks for response @dparsons
Unfortunately I could not install it on my MacPro by the following coomand :
conda install -c conda-forge fenicsx

Is there any other way to install it?

Ah, right. It’s dolfinx you’re after, not dolfin. As you found, conda does not officially provide fenicx yet.

You might want to try accessing it via docker instead.

Ah, I did not know that.
Actually I have created an environment by conda and then installed brew in the same directory.
Then I tried to install all requirements (Boost, cmake, xtensor , …) on that environment by brew and conda both. Is it possible that i install fenicsx by docker on that environment?
Or I need to create a new environment by docker and install all requirements by docker and brew?

I recommend following the instructions on the installation page for using docker.

docker is a separate installation method from conda. Don’t mix them.

1 Like

FEniCSx is now available on conda, see GitHub - FEniCS/dolfinx: Next generation FEniCS problem solving environment for details

Thank you very much Prof Dokken for letting me know

I tried :

!add-apt-repository -y ppa:fenics-packages/fenics
!apt-get -y -qq update
!apt-get -y install dolfinx

This doesn’t seem to work, apt-get doesn’t find dolfinx, i get the following output

E: Unable to locate package dolfinx

I think the correct way to install fenicsx now is:

add-apt-repository ppa:fenics-packages/fenics
apt update
apt install fenicsx

See the link in the previous answer:

The use of ! suggests you’re working on Google’s Colab, not ubuntu directly. Colab is broken, Google has not been willing to fix it. You can find a workaround at

thanks a lot, i am now using fem-on-colab

Is dolfin-adjoint also installed in colab?

I don’t know about dolfin-adjoint. I suspect it is not.