I also tried the solutions suggested here: Error: fenics-dolfinx requires GCC-9 or newer for improved C++17 support but gcc version 10.2.1 in my system - #5 by jiangzhangze. I created a new spack environment and added the command lines:
spack compiler find
spack add py-fenics-dolfinx%gcc cflags="-O3" fflags="-O3"
spack install
and now I get the following errors:
==> Error: concretization failed for the following reasons:
1. fenics-dolfinx: fenics-dolfinx requires GCC-9 or newer for improved C++17 support
2. fenics-dolfinx: fenics-dolfinx requires GCC-9 or newer for improved C++17 support
required because conflict constraint
required because py-fenics-dolfinx depends on fenics-dolfinx@0.4.1 when @0.4.1
required because py-fenics-dolfinx%gcc cflags=-O3 fflags=-O3 requested explicitly
required because conflict is triggered when %gcc@:8
required because py-fenics-dolfinx depends on fenics-dolfinx@0.4.1 when @0.4.1
required because py-fenics-dolfinx%gcc cflags=-O3 fflags=-O3 requested explicitly ```