# Fenics Installation problem using source

**URL:** <https://fenicsproject.discourse.group/t/fenics-installation-problem-using-source/8481>\
**Category:** installation\
**Created:** [June 8, 2022, 4:37am UTC](https://fenicsproject.discourse.group/t/fenics-installation-problem-using-source/8481 "2022-06-08T04:37:19Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anirban\_Mondal](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/anirban_mondal/32/3856_2.png) [@Anirban\_Mondal](https://fenicsproject.discourse.group/u/Anirban_Mondal)\
**Post date:** [June 8, 2022, 4:37am UTC](https://fenicsproject.discourse.group/t/fenics-installation-problem-using-source/8481/1 "2022-06-08T04:37:19Z")

</div>

Hello  
I am using WSL ubuntu 20.04.4 LTS (focal) to use FEniCS. I am following this github instruction page: ([GitHub - FEniCS/dolfinx: Next generation FEniCS problem solving environment](https://github.com/FEniCS/dolfinx)) to install FEniCS in my Ubuntu sub-system. I pass these commands in ubuntu command prompt:

1. (base) fenics@DESKTOP-CVH2BNB:~$ git clone [GitHub - FEniCS/dolfinx: Next generation FEniCS problem solving environment](https://github.com/FEniCS/dolfinx.git)
2. (base) fenics@DESKTOP-CVH2BNB:~/dolfinx/cpp$ cmake …

In the no.2 command output I get this error:

– The C compiler identification is GNU 9.4.0  
– The CXX compiler identification is GNU 9.4.0  
– Check for working C compiler: /usr/bin/cc  
– Check for working C compiler: /usr/bin/cc – works  
– Detecting C compiler ABI info  
– Detecting C compiler ABI info - done  
– Detecting C compile features  
– Detecting C compile features - done  
– Check for working CXX compiler: /usr/bin/c++  
– Check for working CXX compiler: /usr/bin/c++ – works  
– Detecting CXX compiler ABI info  
– Detecting CXX compiler ABI info - done  
– Detecting CXX compile features  
– Detecting CXX compile features - done  
– Could NOT find MPI\_C (missing: MPI\_C\_LIB\_NAMES MPI\_C\_HEADER\_DIR MPI\_C\_WORKS) (Required is at least version “3”)  
– Could NOT find MPI\_CXX (missing: MPI\_CXX\_LIB\_NAMES MPI\_CXX\_HEADER\_DIR MPI\_CXX\_WORKS) (Required is at least version “3”)  
CMake Error at /usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:146 (message):  
Could NOT find MPI (missing: MPI\_C\_FOUND MPI\_CXX\_FOUND) (Required is at  
least version “3”)  
Call Stack (most recent call first):  
/usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:393 (\_FPHSA\_FAILURE\_MESSAGE)  
/usr/share/cmake-3.16/Modules/FindMPI.cmake:1688 (find\_package\_handle\_standard\_args)  
CMakeLists.txt:86 (find\_package)

– Configuring incomplete, errors occurred!  
See also “/home/fenics/dolfinx/cpp/CMakeFiles/CMakeOutput.log”.  
See also “/home/fenics/dolfinx/cpp/CMakeFiles/CMakeError.log”.

I am attaching the CMakeError.log and CMakeOutput.log file.

 ![CMakeErrorLogFile](https://global.discourse-cdn.com/free1/uploads/fenicsproject1/original/2X/1/116479ced991fafc7b21afc081b4c1e50e7fd256.jpeg)

Please help me to solve my issue!  
Thanks

---

<div class="post-metadata">

**Author:** ![dokken](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/dokken/32/1560_2.png) [@dokken](https://fenicsproject.discourse.group/u/dokken)\
**Post date:** [June 8, 2022, 5:28am UTC](https://fenicsproject.discourse.group/t/fenics-installation-problem-using-source/8481/2 "2022-06-08T05:28:55Z")

</div>

Note that DOLFINx has dependencies: [Installation — DOLFINx 0.4.2.0 documentation](https://docs.fenicsproject.org/dolfinx/main/python/installation#dependencies)

You could either: install these or use `docker`, `spack` or `conda`

---

<div class="post-metadata">

**Author:** ![Anirban\_Mondal](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/anirban_mondal/32/3856_2.png) [@Anirban\_Mondal](https://fenicsproject.discourse.group/u/Anirban_Mondal)\
**Post date:** [June 8, 2022, 12:00pm UTC](https://fenicsproject.discourse.group/t/fenics-installation-problem-using-source/8481/3 "2022-06-08T12:00:51Z")

</div>

Have I to install each and every components of C++ and python interface individually before running the above commands?

---

<div class="post-metadata">

**Author:** ![Calva](https://avatars.discourse-cdn.com/v4/letter/c/b9e5f3/32.png) [@Calva](https://fenicsproject.discourse.group/u/Calva)\
**Post date:** [June 8, 2022, 1:57pm UTC](https://fenicsproject.discourse.group/t/fenics-installation-problem-using-source/8481/4 "2022-06-08T13:57:45Z")

</div>

Yes, to compile from source, you need to have every dependency installed on your system.  
Since you are using Ubuntu, you can install most of them with apt.  
However, do not install `basix`, `ffcx`, and `ufl` from apt, they are old versions that are not compatible for compiling the main branch of dolfinx. I recommend you to also build these from source, and install C++ and python interface to your system before attempting to compile `dolfinx`.

---

<div class="post-metadata">

**Author:** ![dokken](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/dokken/32/1560_2.png) [@dokken](https://fenicsproject.discourse.group/u/dokken)\
**Post date:** [June 8, 2022, 2:02pm UTC](https://fenicsproject.discourse.group/t/fenics-installation-problem-using-source/8481/5 "2022-06-08T14:02:30Z")

</div>

If you want to install DOLFINx from source, you need to make sure that your system has all these requirements.  
As I mentioned, there are many other ways to install dolfinx (which does not require alot of manual installations, see: [Installation — DOLFINx 0.4.2.0 documentation](https://docs.fenicsproject.org/dolfinx/main/python/installation.html)  
and  
[Create conda packages · Issue #1505 · FEniCS/dolfinx · GitHub](https://github.com/FEniCS/dolfinx/issues/1505#issuecomment-1148504095)

---

<div class="post-metadata">

**Author:** ![Anirban\_Mondal](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/anirban_mondal/32/3856_2.png) [@Anirban\_Mondal](https://fenicsproject.discourse.group/u/Anirban_Mondal)\
**Post date:** [June 8, 2022, 8:14pm UTC](https://fenicsproject.discourse.group/t/fenics-installation-problem-using-source/8481/6 "2022-06-08T20:14:50Z")

</div>

I am following this webpage to install from source: [[Installation — DOLFINx 0.4.2.0 documentation](https://docs.fenicsproject.org/dolfinx/main/python/installation)]. At the time of installing Basix, using this webpage: [[basix/INSTALL.md at main · FEniCS/basix · GitHub](https://github.com/FEniCS/basix/blob/main/INSTALL.md)], (Advanced installation), I am getting this error:

(base) fenics@DESKTOP-CVH2BNB:~/basix/cpp$ cmake -DCMAKE\_BUILD\_TYPE=Release -B build-dir -S .  
– The CXX compiler identification is GNU 9.4.0  
– Detecting CXX compiler ABI info  
– Detecting CXX compiler ABI info - done  
– Check for working CXX compiler: /usr/bin/c++ - skipped  
– Detecting CXX compile features  
– Detecting CXX compile features - done  
– Performing Test arch\_native\_supported  
– Performing Test arch\_native\_supported - Success  
– Looking for sgemm\_  
– Looking for sgemm\_ - not found  
– Looking for C++ include pthread.h  
– Looking for C++ include pthread.h - found  
– Performing Test CMAKE\_HAVE\_LIBC\_PTHREAD  
– Performing Test CMAKE\_HAVE\_LIBC\_PTHREAD - Failed  
– Looking for pthread\_create in pthreads  
– Looking for pthread\_create in pthreads - not found  
– Looking for pthread\_create in pthread  
– Looking for pthread\_create in pthread - found  
– Found Threads: TRUE  
CMake Error at /home/fenics/.spack/Spack/opt/spack/linux-ubuntu20.04-skylake/gcc-9.4.0/cmake-3.23.2-i6y3jvftz2gzsttrd5tmqdpa77rj5cs5/share/cmake-3.23/Modules/FindPackageHandleStandardArgs.cmake:230 (message):  
Could NOT find BLAS (missing: BLAS\_LIBRARIES)  
Call Stack (most recent call first):  
/home/fenics/.spack/Spack/opt/spack/linux-ubuntu20.04-skylake/gcc-9.4.0/cmake-3.23.2-i6y3jvftz2gzsttrd5tmqdpa77rj5cs5/share/cmake-3.23/Modules/FindPackageHandleStandardArgs.cmake:594 (\_FPHSA\_FAILURE\_MESSAGE)  
/home/fenics/.spack/Spack/opt/spack/linux-ubuntu20.04-skylake/gcc-9.4.0/cmake-3.23.2-i6y3jvftz2gzsttrd5tmqdpa77rj5cs5/share/cmake-3.23/Modules/FindBLAS.cmake:1337 (find\_package\_handle\_standard\_args)  
CMakeLists.txt:66 (find\_package)

– Configuring incomplete, errors occurred!  
See also “/home/fenics/basix/cpp/build-dir/CMakeFiles/CMakeOutput.log”.  
See also “/home/fenics/basix/cpp/build-dir/CMakeFiles/CMakeError.log”.

Any idea how to solve it?

---

<div class="post-metadata">

**Author:** ![Anirban\_Mondal](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/anirban_mondal/32/3856_2.png) [@Anirban\_Mondal](https://fenicsproject.discourse.group/u/Anirban_Mondal)\
**Post date:** [June 8, 2022, 9:48pm UTC](https://fenicsproject.discourse.group/t/fenics-installation-problem-using-source/8481/7 "2022-06-08T21:48:26Z")

</div>

I have used the link you shared ([[dolfinx/README.md at main · FEniCS/dolfinx · GitHub](https://github.com/FEniCS/dolfinx/blob/main/README.md)]) to install dolfinx using SPACK installation. The commands that I have used are (with output):

(base) fenics@DESKTOP-CVH2BNB:~$ cd spack/

(base) fenics@DESKTOP-CVH2BNB:~/spack$ ls  
CHANGELOG.md COPYRIGHT LICENSE-MIT README.md bin lib pyproject.toml share  
CITATION.cff LICENSE-APACHE NOTICE SECURITY.md etc opt pytest.ini var  
(base) fenics@DESKTOP-CVH2BNB:~/spack$ cd share/  
(base) fenics@DESKTOP-CVH2BNB:~/spack/share$ ls  
spack  
(base) fenics@DESKTOP-CVH2BNB:~/spack/share$ cd spack/  
(base) fenics@DESKTOP-CVH2BNB:~/spack/share/spack$ ls  
bash csh docs keys qa setup-env.fish setup-env.sh spack-completion.bash  
bootstrap docker gitlab logo setup-env.csh setup-env.ps1 setup-tutorial-env.sh templates  
(base) fenics@DESKTOP-CVH2BNB:~/spack/share/spack$ bash setup-env.sh  
(base) fenics@DESKTOP-CVH2BNB:~/spack/share/spack$ spack env create fenicsx-env  
(base) fenics@DESKTOP-CVH2BNB:~/spack/share/spack$ spack env activate fenicsx-env  
(base) fenics@DESKTOP-CVH2BNB:~/spack/share/spack$ spack add py-fenics-dolfinx cflags="-O3" fflags="-O3"  
==\> Adding py-fenics-dolfinx cflags="-O3" fflags="-O3" to environment fenicsx-env  
(base) fenics@DESKTOP-CVH2BNB:~/spack/share/spack$ spack install

(I am posting the last error output. I am not posting the intermediate outputs)

==\> Error: py-fenics-dolfinx-0.4.1-qfej72m2pmkr7mznswteim3hk7qydmsz: Package was not installed  
==\> Updating view at /home/fenics/.spack/Spack/var/spack/environments/fenicsx-env/.spack-env/view  
==\> Error: Installation request failed. Refer to reported errors for failing package(s).

Please help!

---

<div class="post-metadata">

**Author:** ![dokken](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/dokken/32/1560_2.png) [@dokken](https://fenicsproject.discourse.group/u/dokken)\
**Post date:** [June 8, 2022, 9:54pm UTC](https://fenicsproject.discourse.group/t/fenics-installation-problem-using-source/8481/8 "2022-06-08T21:54:39Z")

</div>

> [@Anirban\_Mondal](#):
>
> Could NOT find BLAS (missing: BLAS\_LIBRARIES)

As the error says, you do not have BLAS installed.

> [@Anirban\_Mondal](#):
>
> ==\> Error: py-fenics-dolfinx-0.4.1-qfej72m2pmkr7mznswteim3hk7qydmsz: Package was not installed

We would need more of the stack trace than this, as this does not tell us what went wrong.

---

<div class="post-metadata">

**Author:** ![Calva](https://avatars.discourse-cdn.com/v4/letter/c/b9e5f3/32.png) [@Calva](https://fenicsproject.discourse.group/u/Calva)\
**Post date:** [June 8, 2022, 10:21pm UTC](https://fenicsproject.discourse.group/t/fenics-installation-problem-using-source/8481/9 "2022-06-08T22:21:44Z")

</div>

Install a BLAS implementation. On Ubuntu make sure to use a `-dev` package, e.g.

```nohighlight
sudo apt install libopenblas-dev

```

---

<div class="post-metadata">

**Author:** ![Anirban\_Mondal](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/anirban_mondal/32/3856_2.png) [@Anirban\_Mondal](https://fenicsproject.discourse.group/u/Anirban_Mondal)\
**Post date:** [June 9, 2022, 9:05am UTC](https://fenicsproject.discourse.group/t/fenics-installation-problem-using-source/8481/10 "2022-06-09T09:05:10Z")

</div>

I have installed BLAS using $sudo apt install libopenblas-dev and I have also installed GCC and gfortran compiler.

fenics@DESKTOP-CVH2BNB:~$ gcc --version  
gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0

fenics@DESKTOP-CVH2BNB:~$ gfortran --version  
GNU Fortran (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0

When I run $ spack install, I get below stack details with error:

I am unable to post the output here (because of the word limit). So I am attaching the output in a jpeg image format. I am allowed to attach 5 images with this message. So I am attaching the output image in jpeg (only the error portions of the output) in a chronological order.

 ![spack_install_error_1](https://global.discourse-cdn.com/free1/uploads/fenicsproject1/original/2X/4/4513fe78c2a86012d3ff0b6dace7205c9cba9a01.jpeg)  
 ![spack_install_error_2](https://global.discourse-cdn.com/free1/uploads/fenicsproject1/original/2X/8/875933656c29e3043f6cc3d7d1c02b94f15da4c1.jpeg)  
 ![spack_install_error_3](https://global.discourse-cdn.com/free1/uploads/fenicsproject1/original/2X/7/7d1f45f9ed49a9ecbbb9056b01f8890c25114bb1.jpeg)

---

<div class="post-metadata">

**Author:** ![Calva](https://avatars.discourse-cdn.com/v4/letter/c/b9e5f3/32.png) [@Calva](https://fenicsproject.discourse.group/u/Calva)\
**Post date:** [June 9, 2022, 10:21am UTC](https://fenicsproject.discourse.group/t/fenics-installation-problem-using-source/8481/11 "2022-06-09T10:21:50Z")

</div>

It looks like spack is not aware of your `gfortran` installation. Maybe you installed `gfortran` after creating the spack environment?  
Can you try running the following command

```nohighlight
spack compiler find

```

this will force a scan of all available compilers.  
After that, if the same error occurs, please post the output of

```nohighlight
spack compiler info gcc

```

---

<div class="post-metadata">

**Author:** ![Anirban\_Mondal](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/anirban_mondal/32/3856_2.png) [@Anirban\_Mondal](https://fenicsproject.discourse.group/u/Anirban_Mondal)\
**Post date:** [June 10, 2022, 3:16am UTC](https://fenicsproject.discourse.group/t/fenics-installation-problem-using-source/8481/13 "2022-06-10T03:16:15Z")

</div>

fenics@DESKTOP-CVH2BNB:~$ spack compiler find  
==\> Found no new compilers  
==\> Compilers are defined in the following files:  
/home/fenics/.spack/linux/compilers.yaml

fenics@DESKTOP-CVH2BNB:~$ spack compiler info gcc  
gcc@9.4.0:  
paths:  
cc = /usr/bin/gcc  
cxx = /usr/bin/g++  
f77 = None  
fc = None  
modules =   
operating system = ubuntu20.04

---

<div class="post-metadata">

**Author:** ![Calva](https://avatars.discourse-cdn.com/v4/letter/c/b9e5f3/32.png) [@Calva](https://fenicsproject.discourse.group/u/Calva)\
**Post date:** [June 10, 2022, 11:10am UTC](https://fenicsproject.discourse.group/t/fenics-installation-problem-using-source/8481/14 "2022-06-10T11:10:55Z")

</div>

That’s weird. Not sure why spack is unable to find your fortran compiler.  
Not 100% sure it’s gonna help, but you can try editing the `/home/fenics/.spack/linux/compilers.yaml` file manually into something like this:

```auto
spec: gcc@9.4.0:
paths:
    cc = /usr/bin/gcc
    cxx = /usr/bin/g++
    f77 = /usr/bin/gfortran
    fc = /usr/bin/gfortran

```

---

<div class="post-metadata">

**Author:** ![Anirban\_Mondal](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/anirban_mondal/32/3856_2.png) [@Anirban\_Mondal](https://fenicsproject.discourse.group/u/Anirban_Mondal)\
**Post date:** [June 10, 2022, 1:14pm UTC](https://fenicsproject.discourse.group/t/fenics-installation-problem-using-source/8481/15 "2022-06-10T13:14:03Z")

</div>

After updating /home/fenics/.spack/linux/compilers.yaml file manually as you said, the finding compilers error has been solved. Now the new error comes. I have attached the screenshot showing error with this mail. Please help.

 ![page_1](https://global.discourse-cdn.com/free1/uploads/fenicsproject1/original/2X/9/96188008ca13e61b8441ca1cac3192a974ecea08.jpeg)  
 ![page_2](https://global.discourse-cdn.com/free1/uploads/fenicsproject1/original/2X/5/521b7ed4a24d5842b23d7a3ada927146496a1810.jpeg)

---

<div class="post-metadata">

**Author:** ![Calva](https://avatars.discourse-cdn.com/v4/letter/c/b9e5f3/32.png) [@Calva](https://fenicsproject.discourse.group/u/Calva)\
**Post date:** [June 10, 2022, 1:56pm UTC](https://fenicsproject.discourse.group/t/fenics-installation-problem-using-source/8481/16 "2022-06-10T13:56:09Z")

</div>

Not sure about this one. Looks like a download error to me but I do not know how to fix it.  
Maybe somebody else has an idea.

---

<div class="post-metadata">

**Author:** ![Anirban\_Mondal](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/anirban_mondal/32/3856_2.png) [@Anirban\_Mondal](https://fenicsproject.discourse.group/u/Anirban_Mondal)\
**Post date:** [June 10, 2022, 3:42pm UTC](https://fenicsproject.discourse.group/t/fenics-installation-problem-using-source/8481/17 "2022-06-10T15:42:49Z")

</div>

There is a good news I guess. I have run $spack install again and it is installed (I guess) with no error. Now, can you tell me how to run a test case e.g. poisson\_demo.py after installing spack?

---

<div class="post-metadata">

**Author:** ![dokken](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/dokken/32/1560_2.png) [@dokken](https://fenicsproject.discourse.group/u/dokken)\
**Post date:** [June 10, 2022, 3:44pm UTC](https://fenicsproject.discourse.group/t/fenics-installation-problem-using-source/8481/18 "2022-06-10T15:44:00Z")

</div>

simply download the [python file](https://github.com/FEniCS/dolfinx/blob/main/python/demo/demo_poisson.py) and call `python3 demo_poisson.py`.

---

<div class="post-metadata">

**Author:** ![Anirban\_Mondal](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/anirban_mondal/32/3856_2.png) [@Anirban\_Mondal](https://fenicsproject.discourse.group/u/Anirban_Mondal)\
**Post date:** [June 10, 2022, 4:28pm UTC](https://fenicsproject.discourse.group/t/fenics-installation-problem-using-source/8481/19 "2022-06-10T16:28:03Z")

</div>

fenics@DESKTOP-CVH2BNB:~$ ls  
Pipfile basix dolfinx parmetis spack  
Pipfile.lock boost\_1\_79\_0 ffcx petsc ufl  
Untitled.ipynb boost\_1\_79\_0\_rc1.tar.gz install\_fenics\_And\_running\_poisson.py slepc-3.17.1.tar.gz  
anaconda3 demo\_poisson.py mamba-framework slepc4py-3.12.0.tar.gz

fenics@DESKTOP-CVH2BNB:~$ python3 demo\_poisson.py  
Traceback (most recent call last):  
File “demo\_poisson.py”, line 73, in   
from dolfinx import fem, io, mesh, plot  
ImportError: cannot import name ‘fem’ from ‘dolfinx’ (unknown location)

---

<div class="post-metadata">

**Author:** ![dokken](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/dokken/32/1560_2.png) [@dokken](https://fenicsproject.discourse.group/u/dokken)\
**Post date:** [June 10, 2022, 4:33pm UTC](https://fenicsproject.discourse.group/t/fenics-installation-problem-using-source/8481/20 "2022-06-10T16:33:03Z")

</div>

What happens if you call  
`spack load py-fenics-dolfinx`

---

<div class="post-metadata">

**Author:** ![Anirban\_Mondal](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/anirban_mondal/32/3856_2.png) [@Anirban\_Mondal](https://fenicsproject.discourse.group/u/Anirban_Mondal)\
**Post date:** [June 10, 2022, 4:55pm UTC](https://fenicsproject.discourse.group/t/fenics-installation-problem-using-source/8481/21 "2022-06-10T16:55:30Z")

</div>

I think spack is not installed properly. Should I run $spack install again and show you the outcome?

fenics@DESKTOP-CVH2BNB:~$ spack load py-fenics-dolfinx

Command ‘spack’ not found, did you mean:

command ‘fpack’ from deb libcfitsio-bin (3.470-3)  
command ‘mpack’ from deb mpack (1.6-8.2)  
command ‘stack’ from deb haskell-stack (1.9.3.1-1)  
command ‘cpack’ from deb cmake (3.16.3-1ubuntu1)  
command ‘ipack’ from deb exult-studio (1.2-18build1)  
command ‘slack’ from deb slack (1:0.15.2-9)  
command ‘apack’ from deb atool (0.39.0-10)  
command ‘hpack’ from deb hpack (0.31.2-1)  
command ‘spock’ from deb python3-sardana (3.0.2a0+34.9f6895-1)  
command ‘pack’ from deb liballegro4-dev (2:4.4.3.1-1)

Try: sudo apt install

[Next page](https://fenicsproject.discourse.group/t/fenics-installation-problem-using-source/8481.md?page=2)
