Walkthrough of Installation


Can anyone walk me through the installation of Fenicsx step by step? I have no idea how to build the C++ core and I need to use it for my PDES class this weekend. Any help would be super super appreciated.

I would suggest having a look at: GitHub - FEniCS/dolfinx: Next generation FEniCS problem solving environment

In general, I would not recommend installing it from source (especially if you haven’t done it before).

There are many other ways of obtaining FEniCSx, see GitHub - FEniCS/dolfinx: Next generation FEniCS problem solving environment

Would installing it through the environment give me all the packages necessary?

Alexander Brower

You have not specified what environment you are considering.

If you mean conda:
It installs all required dependencies to run DOLFINx (including petsc and adios2).

You can see all the deps that are installed at fenics-dolfinx-feedstock/meta.yaml at main · conda-forge/fenics-dolfinx-feedstock · GitHub

Okay, I am trying to download and use Fenicsx on my personal windows laptop. I plan on working in Spyder or Visual Studio Code. I saw conda is not recommended for windows since the packages aren’t supported through conda. So I did the following:

  1. I installed docker and ran
    docker run -ti dolfinx/dolfinx:stable

My question now is where do I go from here? How do I finish installing the rest of the fenics/dolfin packages to be able to successfully work in Sypder or VS Code.

I’m sorry for all the questions, I’ve never had to go through such a process. I appreciate the help.

Alexander Brower

In the terminal this spawns, you can run any script with dolfinx in it. Everything is installed.

As you probably want to write scripts on your own computer, you should mount a volume (share a directory of your computer with the docker container).
See for instance Installation problems - #16 by dokken
and all subsequent posts

Alright, I will try this out and let you know how it goes. Thanks for all the help, I really appreciate it.

Alexander Brower

Okay so a little change of pace. I am on my work Mac and I have successfully run the conda-forge installation through a fenicsx-env in terminal!

But, when I go to use the packages in VS Code, I am hit with errors.
(fenicsx-env) brower@BGMATHMC524-A ~ % python3 test.py Traceback (most recent call last): File "/Users/brower/test.py", line 1, in <module> from mpi4py import MPI ModuleNotFoundError: No module named 'mpi4py' (fenicsx-env) brower@BGMATHMC524-A ~ % pip install mpi4py Requirement already satisfied: mpi4py in ./opt/anaconda3/envs/fenicsx-env/lib/python3.10/site-packages (3.1.4)

the test code is from the first part of tutorial:

from mpi4py import MPI
from dolfinx import mesh
domain = mesh.create_unit_square(MPI.COMM_WORLD, 8, 8, mesh.CellType.quadrilateral)

I expect a similar problem with the dolfinx package.

Hope you can help! Thanks!

could you call which python3, as you might need to use python test.py as you are using conda.

(fenicsx-env) brower@BGMATHMC524-A ~ % which python3

This is all that comes up

Running with python test.py gives

(fenicsx-env) brower@BGMATHMC524-A ~ % python test.py
Traceback (most recent call last):
  File "test.py", line 1, in <module>
    from mpi4py import MPI
ImportError: No module named mpi4py

You should be using the conda-environment Python.

I am not sure why it is not overloaded (as you have activated your conda env).
Could you try something along the lines of


Do I try in the fenicsx env or in my base?

In your FEniCSx-env.

1 Like
(fenicsx-env) brower@BGMATHMC524-A ~ % ./opt/anaconda3/envs/fenicsx-env/bin/python 
Python 3.10.9 | packaged by conda-forge | (main, Feb  2 2023, 20:24:27) [Clang 14.0.6 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.

is the output I get, and then it goes to just a blank line like


So I think its working now? How do I run a program in the blank lines? Is it just the code itself? Or is there a way to run the whole script at once?

./opt/anaconda3/envs/fenicsx-env/bin/python test.py

We’re good!!! Thank you so much!!!