FEniCSx / Installation errors

Causes and fixes for FEniCSx installation errors

Common errors when installing FEniCSx (DOLFINx) and running a first example, listed by exact message, each with its cause and fix.

Short answer

FEniCSx depends on PETSc, MPI and a set of FEniCS components whose versions must match, PETSc does not support Windows, and legacy FEniCS and FEniCSx use different package names, so the wrong system, environment or version breaks import.

Setting up your environment this way avoids most errors on this page.

PracticeWhat happens if you skip it
On Linux and macOS, create a new environment with conda create -n fenicsx -c conda-forge fenics-dolfinx mpich pyvista.Mixed into an environment with other packages, component versions conflict and import fails.
On Windows, install inside Ubuntu on WSL2 or use the Docker image dolfinx/dolfinx:stable.The Windows build has no PETSc, and solver code fails with No module named petsc4py.
Write new code for FEniCSx with import dolfinx.Following legacy FEniCS tutorials with from dolfin import * fails with No module named dolfin.
Run scripts with the environment's python and mpirun.The system python or another MPI causes missing mpi4py or MPI errors.
Do not pin components such as petsc4py on their own.conda falls back to a very old dolfinx to satisfy the pin, causing odd runtime errors.

Troubleshooting by error message

Find your exact error message. Each entry gives the cause, the fix, and what may come up after the fix.

ModuleNotFoundError: No module named 'petsc4py' (on Windows, from dolfinx.fem.petsc import LinearProblem)

Cause: PETSc and petsc4py do not support Windows, so dolfinx installed by conda on Windows ships without them.

Fix: Reinstall FEniCSx inside Ubuntu on WSL2; for simple solves, switch to the pyamg solver following the official demo_pyamg.py.

What may come next: In WSL2 you need conda and the other dependencies again, and case files must be somewhere WSL2 can reach.

ModuleNotFoundError: No module named 'dolfin'

Cause: The code targets legacy FEniCS (dolfin, last released as 2019.1.0) while the environment has FEniCSx (dolfinx), and their package names and APIs differ.

Fix: Port the code to FEniCSx with import dolfinx; to reproduce an old tutorial only, use a legacy FEniCS Docker image.

What may come next: Legacy FEniCS is rarely updated and hard to install on new systems, so long-term use means moving to FEniCSx.

ModuleNotFoundError: No module named 'mpi4py'

Cause: The script ran with the system python3 instead of the python in the FEniCSx conda environment.

Fix: Run conda activate for the environment first, or run the script with the full path of the environment's python.

[0]PETSC ERROR: Caught signal number 4 Illegal instruction: Likely due to memory corruption

Cause: The CPU lacks an instruction set (such as AVX) used by the conda packages, typical in VMs configured with a compatibility CPU type or on old CPUs.

Fix: In a VM, set the CPU type to host passthrough; on an old physical CPU, use the Docker image dolfinx/dolfinx:stable.

AttributeError: module 'ufl.sobolevspace' has no attribute 'HInf'

Cause: ufl and dolfinx versions do not match, typically because FEniCS components of different versions are mixed in one environment or the IDE did not activate the environment properly.

Fix: Create a fresh environment with only FEniCSx; in VS Code make sure the selected interpreter is that environment, and if needed activate it in a terminal before launching VS Code.

ImportError: dlopen(.../libffcx_forms_....so) (duplicate LC_RPATH ...) (calling dolfinx.fem.form on macOS)

Cause: A petsc4py pin at environment creation made conda fall back to the old dolfinx 0.9.0, whose compiled forms fail to load on recent macOS.

Fix: Create a new environment with a current version, for example conda install -c conda-forge fenics-dolfinx=0.11 "petsc=*=complex*" mpich.

Scientify is a cloud computer with research software installed and AI agents such as Codex and Claude Code built in. Describe what you need in one sentence, for example "solve the steady-state temperature field of this heated steel plate with FEniCSx and plot the temperature map", and the agent uses the preinstalled FEniCSx to do the modeling and computation, with no software to install and no code to write.

Compared with installing more on your own computer, the cloud computer already has FEniCSx (DOLFINx 0.11.0) with matching PETSc 3.25.6, petsc4py, SLEPc, OpenMPI and the Gmsh 4.15.2 mesher, and runs continue after you close your laptop.

The cloud computer comes with more computing power: CPU and GPU clusters can be called on demand for large-scale scientific computing. Compute is billed by the minutes you actually use, so nothing is wasted.

Cloud computer
4 vCPU · 8 GB
Top configuration, for data processing and small to medium jobs
Callable GPU
96 GB VRAM
Up to an RTX PRO 6000 per GPU; H800 80 GB and up to 8 × A10G also available
Callable CPU
224 cores · 3 TB
Largest spec, for large parallel computations

References

Frequently asked questions

What is the difference between FEniCS and FEniCSx?

FEniCSx is the new generation whose core library is DOLFINx, used with import dolfinx; legacy FEniCS uses DOLFIN and has barely changed since 2019.1.0. Their APIs are not compatible.

How do I use FEniCSx on Windows?

Install it with conda or apt inside Ubuntu on WSL2, or use a Docker image. The native Windows conda package has no PETSc, so many solvers are unavailable.

How do I run FEniCSx in parallel?

Use the environment's mpirun, for example mpirun -n 4 python script.py; the mesh is partitioned across processes automatically.

Run finite element simulations with Scientify without setup

Upload your data, describe the computation, and Scientify runs it on a cloud computer that is already set up. New accounts get a free cloud computer and US$5 in credit.