conda-forge / fenics-feedstock

A conda-smithy repository for fenics.
BSD 3-Clause "New" or "Revised" License
13 stars 12 forks source link

Can't use fenics from conda #164

Closed RemDelaporteMathurin closed 2 years ago

RemDelaporteMathurin commented 2 years ago

Solution to issue cannot be found in the documentation.

Issue

Hi, I'm trying to install fenics via conda since I need a newer version of python.

I'm using the continuumio/miniconda3 docker image to install fenics via:

conda install -c conda-forge fenics

Everything works fine on my windows machine, but when running on ubuntu it seems that the c++ files are not found:

Traceback (most recent call last):
  File "/__w/FESTIM-workshop/FESTIM-workshop/tasks/task1.py", line 74, in <module>
    my_model.initialise()
  File "/opt/conda/lib/python3.9/site-packages/festim/generic_simulation.py", line 237, in initialise
    self.V_DG1 = FunctionSpace(self.mesh.mesh, "DG", 1)
  File "/opt/conda/lib/python3.9/site-packages/dolfin/function/functionspace.py", line 33, in __init__
    self._init_convenience(*args, **kwargs)
  File "/opt/conda/lib/python3.9/site-packages/dolfin/function/functionspace.py", line 100, in _init_convenience
    self._init_from_ufl(mesh, element, constrained_domain=constrained_domain)
  File "/opt/conda/lib/python3.9/site-packages/dolfin/function/functionspace.py", line 42, in _init_from_ufl
    ufc_element, ufc_dofmap = ffc_jit(element, form_compiler_parameters=None,
  File "/opt/conda/lib/python3.9/site-packages/dolfin/jit/jit.py", line 47, in mpi_jit
    return local_jit(*args, **kwargs)
  File "/opt/conda/lib/python3.9/site-packages/dolfin/jit/jit.py", line 97, in ffc_jit
    return ffc.jit(ufl_form, parameters=p)
  File "/opt/conda/lib/python3.9/site-packages/ffc/jitcompiler.py", line 217, in jit
    module = jit_build(ufl_object, module_name, parameters)
  File "/opt/conda/lib/python3.9/site-packages/ffc/jitcompiler.py", line [13](https://github.com/RemDelaporteMathurin/FESTIM-workshop/runs/7743762381?check_suite_focus=true#step:6:14)0, in jit_build
    module, signature = dijitso.jit(jitable=ufl_object,
  File "/opt/conda/lib/python3.9/site-packages/dijitso/jit.py", line 177, in jit
    build_shared_library(signature, header, source, dependencies,
  File "/opt/conda/lib/python3.9/site-packages/dijitso/build.py", line [15](https://github.com/RemDelaporteMathurin/FESTIM-workshop/runs/7743762381?check_suite_focus=true#step:6:16)3, in build_shared_library
    status, output = get_status_output(cmd)
  File "/opt/conda/lib/python3.9/site-packages/dijitso/system.py", line 40, in _get_status_output_subprocess
    pipe = subprocess.Popen(cmd, shell=False, cwd=cwd, env=env,
  File "/opt/conda/lib/python3.9/subprocess.py", line 951, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/opt/conda/lib/python3.9/subprocess.py", line [18](https://github.com/RemDelaporteMathurin/FESTIM-workshop/runs/7743762381?check_suite_focus=true#step:6:19)[21](https://github.com/RemDelaporteMathurin/FESTIM-workshop/runs/7743762381?check_suite_focus=true#step:6:22), in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'c++'

Full error message here

Here is the github actions file.

Installed packages

# Name                    Version                   Build  Channel
_libgcc_mutex             0.1                        main  
_openmp_mutex             4.5                       1_gnu  
attrs                     22.1.0                   pypi_0    pypi
beautifulsoup4            4.11.1                   pypi_0    pypi
binutils_impl_linux-64    2.35.1               h27ae35d_9  
binutils_linux-64         2.35                h67ddf6f_30    conda-forge
bleach                    5.0.1                    pypi_0    pypi
boost-cpp                 1.74.0               h312852a_4    conda-forge
brotlipy                  0.7.0           py39h27cfd23_1003  
bzip2                     1.0.8                h7f98852_4    conda-forge
c-ares                    1.17.1               h7f98852_1    conda-forge
ca-certificates           2022.6.15            ha878542_0    conda-forge
certifi                   2022.6.15        py39hf3d152e_0    conda-forge
cffi                      1.15.0           py39hd667e15_1  
cftime                    1.6.1                    pypi_0    pypi
charset-normalizer        2.0.4              pyhd3eb1b0_0  
cmake                     3.21.1               h8897547_0    conda-forge
colorama                  0.4.4              pyhd3eb1b0_0  
commonmark                0.9.1                    pypi_0    pypi
conda                     4.13.0           py39hf3d152e_1    conda-forge
conda-content-trust       0.1.1              pyhd3eb1b0_0  
conda-package-handling    1.8.1            py39h7f8727e_0  
crossrefapi               1.5.0                    pypi_0    pypi
cryptography              36.0.0           py39h9ce1e76_0  
cycler                    0.11.0                   pypi_0    pypi
defusedxml                0.7.1                    pypi_0    pypi
eigen                     3.3.9                h4bd325d_1    conda-forge
entrypoints               0.4                      pypi_0    pypi
expat                     2.4.1                h9c3ff4c_0    conda-forge
fastjsonschema            2.16.1                   pypi_0    pypi
fenics                    2019.1.0        py39hf3d152e_21    conda-forge
fenics-dijitso            2019.1.0        py39hf3d152e_21    conda-forge
fenics-dolfin             2019.1.0        py39hc6fefde_21    conda-forge
fenics-ffc                2019.1.0        py39hf3d152e_21    conda-forge
fenics-fiat               2019.1.0        py39hf3d152e_21    conda-forge
fenics-libdolfin          2019.1.0            h5ba192a_21    conda-forge
fenics-ufl                2019.1.0        py39hf3d152e_21    conda-forge
festim                    0.10.2                   pypi_0    pypi
fonttools                 4.34.4                   pypi_0    pypi
gcc_impl_linux-64         9.3.0               h70c0ae5_19    conda-forge
gcc_linux-64              9.3.0               hf25ea35_30    conda-forge
gmp                       6.2.1                h58526e2_0    conda-forge
gmpy2                     2.1.0b5          py39h78fa15d_0    conda-forge
gxx_impl_linux-64         9.3.0               hd87eabc_19    conda-forge
gxx_linux-64              9.3.0               h3fbe746_30    conda-forge
h-transport-materials     0.4.0                    pypi_0    pypi
h5py                      3.7.0                    pypi_0    pypi
hdf5                      1.10.6          mpi_mpich_h996c276_1014    conda-forge
hypre                     2.18.2               hc98498a_1    conda-forge
icu                       68.1                 h58526e2_0    conda-forge
idna                      3.3                pyhd3eb1b0_0  
jinja2                    3.1.2                    pypi_0    pypi
jsonschema                4.9.1                    pypi_0    pypi
jupyter-client            7.3.4                    pypi_0    pypi
jupyter-core              4.11.1                   pypi_0    pypi
jupyterlab-pygments       0.2.2                    pypi_0    pypi
kernel-headers_linux-64   2.6.32              he073ed8_15    conda-forge
kiwisolver                1.4.4                    pypi_0    pypi
krb5                      1.19.2               hcc1bbae_0    conda-forge
latexcodec                2.0.1                    pypi_0    pypi
ld_impl_linux-64          2.35.1               h7274673_9  
libblas                   3.9.0           11_linux64_openblas    conda-forge
libcblas                  3.9.0           11_linux64_openblas    conda-forge
libcurl                   7.78.0               h2574ce0_0    conda-forge
libedit                   3.1.20191231         he28a2e2_2    conda-forge
libev                     4.33                 h516909a_1    conda-forge
libffi                    3.3                  he6710b0_2  
libgcc-devel_linux-64     9.3.0               h7864c58_19    conda-forge
libgcc-ng                 9.3.0               h5101ec6_17  
libgfortran-ng            12.1.0              h69a702a_16    conda-forge
libgfortran5              12.1.0              hdcd56e2_16    conda-forge
libgomp                   9.3.0               h5101ec6_17  
liblapack                 3.9.0           11_linux64_openblas    conda-forge
libnghttp2                1.43.0               h812cca2_0    conda-forge
libopenblas               0.3.17          pthreads_h8fe5266_1    conda-forge
libssh2                   1.9.0                ha56f1ee_6    conda-forge
libstdcxx-devel_linux-64  9.3.0               hb016644_19    conda-forge
libstdcxx-ng              9.3.0               hd4cf53a_17  
libuv                     1.42.0               h7f98852_0    conda-forge
lz4-c                     1.9.3                h9c3ff4c_1    conda-forge
markupsafe                2.1.1                    pypi_0    pypi
matplotlib                3.5.2                    pypi_0    pypi
meshio                    5.3.4                    pypi_0    pypi
metis                     5.1.0             h58526e2_1006    conda-forge
mistune                   0.8.4                    pypi_0    pypi
mpc                       1.2.1                h9f54685_0    conda-forge
mpfr                      4.1.0                h9202a9a_1    conda-forge
mpi                       1.0                       mpich    conda-forge
mpi4py                    3.0.3            py39h6438238_7    conda-forge
mpich                     3.4.2              h846660c_100    conda-forge
mpmath                    1.2.1              pyhd8ed1ab_0    conda-forge
mumps-include             5.2.1               ha770c72_10    conda-forge
mumps-mpi                 5.2.1               hd6b9cac_10    conda-forge
nbclient                  0.6.6                    pypi_0    pypi
nbconvert                 6.5.0                    pypi_0    pypi
nbformat                  5.4.0                    pypi_0    pypi
ncurses                   6.3                  h7f8727e_2  
nest-asyncio              1.5.5                    pypi_0    pypi
netcdf4                   1.6.0                    pypi_0    pypi
numpy                     1.21.1           py39hdbf815f_0    conda-forge
openssl                   1.1.1q               h7f8727e_0  
packaging                 21.3                     pypi_0    pypi
pandocfilters             1.5.0                    pypi_0    pypi
parmetis                  4.0.3             h2a9763c_1005    conda-forge
petsc                     3.14.5               h60475ce_0    conda-forge
petsc4py                  3.14.1           py39h16c3f58_1    conda-forge
pillow                    9.2.0                    pypi_0    pypi
pip                       22.2.2                   pypi_0    pypi
pkg-config                0.29.2            h36c2ea0_1008    conda-forge
pkgconfig                 1.5.5            py39hf3d152e_2    conda-forge
ptscotch                  6.0.9                h253636d_1    conda-forge
pybind11                  2.6.2            py39h1a9c180_0    conda-forge
pybind11-global           2.6.2            py39h1a9c180_0    conda-forge
pybtex                    0.24.0                   pypi_0    pypi
pycosat                   0.6.3            py39h27cfd23_0  
pycparser                 2.21               pyhd3eb1b0_0  
pygments                  2.12.0                   pypi_0    pypi
pyopenssl                 22.0.0             pyhd3eb1b0_0  
pyparsing                 3.0.9                    pypi_0    pypi
pyrsistent                0.18.1                   pypi_0    pypi
pysocks                   1.7.1            py39h06a4308_0  
python                    3.9.12               h12debd9_0  
python-dateutil           2.8.2                    pypi_0    pypi
python_abi                3.9                      2_cp39    conda-forge
pyyaml                    6.0                      pypi_0    pypi
pyzmq                     23.2.0                   pypi_0    pypi
readline                  8.1.2                h7f8727e_1  
requests                  2.27.1             pyhd3eb1b0_0  
rhash                     1.4.1                h7f98852_0    conda-forge
rich                      12.5.1                   pypi_0    pypi
ruamel_yaml               0.15.100         py39h27cfd23_0  
scalapack                 2.0.2             hf659fdc_1009    conda-forge
scipy                     1.9.0                    pypi_0    pypi
scotch                    6.0.9                h3858553_1    conda-forge
setuptools                61.2.0           py39h06a4308_0  
six                       1.16.0             pyhd3eb1b0_1  
slepc                     3.14.2               h44d3fa2_0    conda-forge
slepc4py                  3.14.0           py39h1e75aa9_1    conda-forge
soupsieve                 2.3.2.post1              pypi_0    pypi
sqlite                    3.38.2               hc218d9a_0  
suitesparse               5.6.0                h717dc36_0    conda-forge
superlu                   5.2.2                h16cfea0_0    conda-forge
superlu_dist              6.2.0                h25dcc4a_4    conda-forge
sympy                     1.10.1           py39hf3d152e_0    conda-forge
sysroot_linux-64          2.12                he073ed8_15    conda-forge
tbb                       2020.2               h4bd325d_4    conda-forge
tinycss2                  1.1.1                    pypi_0    pypi
tk                        8.6.11               h1ccaba5_0  
tornado                   6.2                      pypi_0    pypi
tqdm                      4.63.0             pyhd3eb1b0_0  
traitlets                 5.3.0                    pypi_0    pypi
tzdata                    2022a                hda174b7_0  
urllib3                   1.26.8             pyhd3eb1b0_0  
webencodings              0.5.1                    pypi_0    pypi
wheel                     0.37.1             pyhd3eb1b0_0  
xz                        5.2.5                h7b6447c_0  
yaml                      0.2.5                h7b6447c_0  
zlib                      1.2.12               h7f8727e_1  
zstd                      1.5.0                ha95c52a_0    conda-forge

Environment info

active environment : None
       user config file : /github/home/.condarc
 populated config files : 
          conda version : 4.13.0
    conda-build version : not installed
         python version : 3.9.12.final.0
       virtual packages : __linux=5.15.0=0
                          __glibc=2.31=0
                          __unix=0=0
                          __archspec=1=x86_64
       base environment : /opt/conda  (writable)
      conda av data dir : /opt/conda/etc/conda
  conda av metadata url : None
           channel URLs : https://repo.anaconda.com/pkgs/main/linux-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/r/linux-64
                          https://repo.anaconda.com/pkgs/r/noarch
          package cache : /opt/conda/pkgs
                          /github/home/.conda/pkgs
       envs directories : /opt/conda/envs
                          /github/home/.conda/envs
               platform : linux-64
             user-agent : conda/4.13.0 requests/2.27.1 CPython/3.9.12 Linux/5.15.0-1014-azure debian/11 glibc/2.31
                UID:GID : 0:0
             netrc file : None
           offline mode : False
RemDelaporteMathurin commented 2 years ago

It seems this issue is similar to https://github.com/conda-forge/fenics-feedstock/issues/87

RemDelaporteMathurin commented 2 years ago

this is the list of packages on my Windows machine (same docker image) where everything works fine:

_libgcc_mutex             0.1                        main
_openmp_mutex             4.5                       1_gnu
attrs                     22.1.0                   pypi_0    pypi
beautifulsoup4            4.11.1                   pypi_0    pypi
binutils_impl_linux-64    2.35.1               h27ae35d_9
binutils_linux-64         2.35                h67ddf6f_30    conda-forge
bleach                    5.0.1                    pypi_0    pypi
boost-cpp                 1.74.0               h312852a_4    conda-forge
brotlipy                  0.7.0           py39h27cfd23_1003
bzip2                     1.0.8                h7f98852_4    conda-forge
c-ares                    1.17.1               h7f98852_1    conda-forge
ca-certificates           2022.6.15            ha878542_0    conda-forge
certifi                   2022.6.15        py39hf3d152e_0    conda-forge
cffi                      1.15.0           py39hd667e15_1
cftime                    1.6.1                    pypi_0    pypi
charset-normalizer        2.0.4              pyhd3eb1b0_0
cmake                     3.21.1               h8897547_0    conda-forge
colorama                  0.4.4              pyhd3eb1b0_0
commonmark                0.9.1                    pypi_0    pypi
conda                     4.13.0           py39hf3d152e_1    conda-forge
conda-content-trust       0.1.1              pyhd3eb1b0_0
conda-package-handling    1.8.1            py39h7f8727e_0
crossrefapi               1.5.0                    pypi_0    pypi
cryptography              36.0.0           py39h9ce1e76_0
cycler                    0.11.0                   pypi_0    pypi
defusedxml                0.7.1                    pypi_0    pypi
eigen                     3.3.9                h4bd325d_1    conda-forge
entrypoints               0.4                      pypi_0    pypi
expat                     2.4.1                h9c3ff4c_0    conda-forge
fastjsonschema            2.16.1                   pypi_0    pypi
fenics                    2019.1.0        py39hf3d152e_21    conda-forge
fenics-dijitso            2019.1.0        py39hf3d152e_21    conda-forge
fenics-dolfin             2019.1.0        py39hc6fefde_21    conda-forge
fenics-ffc                2019.1.0        py39hf3d152e_21    conda-forge
fenics-fiat               2019.1.0        py39hf3d152e_21    conda-forge
fenics-libdolfin          2019.1.0            h5ba192a_21    conda-forge
fenics-ufl                2019.1.0        py39hf3d152e_21    conda-forge
festim                    0.10.2                   pypi_0    pypi
fonttools                 4.34.4                   pypi_0    pypi
gcc_impl_linux-64         9.3.0               h70c0ae5_19    conda-forge
gcc_linux-64              9.3.0               hf25ea35_30    conda-forge
gmp                       6.2.1                h58526e2_0    conda-forge
gmpy2                     2.1.0b5          py39h78fa15d_0    conda-forge
gxx_impl_linux-64         9.3.0               hd87eabc_19    conda-forge
gxx_linux-64              9.3.0               h3fbe746_30    conda-forge
h-transport-materials     0.4.0                    pypi_0    pypi
h5py                      3.7.0                    pypi_0    pypi
hdf5                      1.10.6          mpi_mpich_h996c276_1014    conda-forge
hypre                     2.18.2               hc98498a_1    conda-forge
icu                       68.1                 h58526e2_0    conda-forge
idna                      3.3                pyhd3eb1b0_0
jinja2                    3.1.2                    pypi_0    pypi
jsonschema                4.9.1                    pypi_0    pypi
jupyter-client            7.3.4                    pypi_0    pypi
jupyter-core              4.11.1                   pypi_0    pypi
jupyterlab-pygments       0.2.2                    pypi_0    pypi
kernel-headers_linux-64   2.6.32              he073ed8_15    conda-forge
kiwisolver                1.4.4                    pypi_0    pypi
krb5                      1.19.2               hcc1bbae_0    conda-forge
latexcodec                2.0.1                    pypi_0    pypi
ld_impl_linux-64          2.35.1               h7274673_9
libblas                   3.9.0           11_linux64_openblas    conda-forge
libcblas                  3.9.0           11_linux64_openblas    conda-forge
libcurl                   7.78.0               h2574ce0_0    conda-forge
libedit                   3.1.20191231         he28a2e2_2    conda-forge
libev                     4.33                 h516909a_1    conda-forge
libffi                    3.3                  he6710b0_2
libgcc-devel_linux-64     9.3.0               h7864c58_19    conda-forge
libgcc-ng                 9.3.0               h5101ec6_17
libgfortran-ng            12.1.0              h69a702a_16    conda-forge
libgfortran5              12.1.0              hdcd56e2_16    conda-forge
libgomp                   9.3.0               h5101ec6_17
liblapack                 3.9.0           11_linux64_openblas    conda-forge
libnghttp2                1.43.0               h812cca2_0    conda-forge
libopenblas               0.3.17          pthreads_h8fe5266_1    conda-forge
libssh2                   1.9.0                ha56f1ee_6    conda-forge
libstdcxx-devel_linux-64  9.3.0               hb016644_19    conda-forge
libstdcxx-ng              9.3.0               hd4cf53a_17
libuv                     1.42.0               h7f98852_0    conda-forge
lz4-c                     1.9.3                h9c3ff4c_1    conda-forge
markupsafe                2.1.1                    pypi_0    pypi
matplotlib                3.5.2                    pypi_0    pypi
meshio                    5.3.4                    pypi_0    pypi
metis                     5.1.0             h58526e2_1006    conda-forge
mistune                   0.8.4                    pypi_0    pypi
mpc                       1.2.1                h9f54685_0    conda-forge
mpfr                      4.1.0                h9202a9a_1    conda-forge
mpi                       1.0                       mpich    conda-forge
mpi4py                    3.0.3            py39h6438238_7    conda-forge
mpich                     3.4.2              h846660c_100    conda-forge
mpmath                    1.2.1              pyhd8ed1ab_0    conda-forge
mumps-include             5.2.1               ha770c72_10    conda-forge
mumps-mpi                 5.2.1               hd6b9cac_10    conda-forge
nbclient                  0.6.6                    pypi_0    pypi
nbconvert                 6.5.0                    pypi_0    pypi
nbformat                  5.4.0                    pypi_0    pypi
ncurses                   6.3                  h7f8727e_2
nest-asyncio              1.5.5                    pypi_0    pypi
netcdf4                   1.6.0                    pypi_0    pypi
numpy                     1.21.1           py39hdbf815f_0    conda-forge
openssl                   1.1.1q               h7f8727e_0
packaging                 21.3                     pypi_0    pypi
pandocfilters             1.5.0                    pypi_0    pypi
parmetis                  4.0.3             h2a9763c_1005    conda-forge
petsc                     3.14.5               h60475ce_0    conda-forge
petsc4py                  3.14.1           py39h16c3f58_1    conda-forge
pillow                    9.2.0                    pypi_0    pypi
pip                       21.2.4           py39h06a4308_0
pkg-config                0.29.2            h36c2ea0_1008    conda-forge
pkgconfig                 1.5.5            py39hf3d152e_2    conda-forge
ptscotch                  6.0.9                h253636d_1    conda-forge
pybind11                  2.6.2            py39h1a9c180_0    conda-forge
pybind11-global           2.6.2            py39h1a9c180_0    conda-forge
pybtex                    0.24.0                   pypi_0    pypi
pycosat                   0.6.3            py39h27cfd23_0
pycparser                 2.21               pyhd3eb1b0_0
pygments                  2.12.0                   pypi_0    pypi
pyopenssl                 22.0.0             pyhd3eb1b0_0
pyparsing                 3.0.9                    pypi_0    pypi
pyrsistent                0.18.1                   pypi_0    pypi
pysocks                   1.7.1            py39h06a4308_0
python                    3.9.12               h12debd9_0
python-dateutil           2.8.2                    pypi_0    pypi
python_abi                3.9                      2_cp39    conda-forge
pyyaml                    6.0                      pypi_0    pypi
pyzmq                     23.2.0                   pypi_0    pypi
readline                  8.1.2                h7f8727e_1
requests                  2.27.1             pyhd3eb1b0_0
rhash                     1.4.1                h7f98852_0    conda-forge
rich                      12.5.1                   pypi_0    pypi
ruamel_yaml               0.15.100         py39h27cfd23_0
scalapack                 2.0.2             hf659fdc_1009    conda-forge
scipy                     1.9.0                    pypi_0    pypi
scotch                    6.0.9                h3858553_1    conda-forge
setuptools                61.2.0           py39h06a4308_0
six                       1.16.0             pyhd3eb1b0_1
slepc                     3.14.2               h44d3fa2_0    conda-forge
slepc4py                  3.14.0           py39h1e75aa9_1    conda-forge
soupsieve                 2.3.2.post1              pypi_0    pypi
sqlite                    3.38.2               hc218d9a_0
suitesparse               5.6.0                h717dc36_0    conda-forge
superlu                   5.2.2                h16cfea0_0    conda-forge
superlu_dist              6.2.0                h25dcc4a_4    conda-forge
sympy                     1.10.1           py39hf3d152e_0    conda-forge
sysroot_linux-64          2.12                he073ed8_15    conda-forge
tbb                       2020.2               h4bd325d_4    conda-forge
tinycss2                  1.1.1                    pypi_0    pypi
tk                        8.6.11               h1ccaba5_0
tornado                   6.2                      pypi_0    pypi
tqdm                      4.63.0             pyhd3eb1b0_0
traitlets                 5.3.0                    pypi_0    pypi
tzdata                    2022a                hda174b7_0
urllib3                   1.26.8             pyhd3eb1b0_0
webencodings              0.5.1                    pypi_0    pypi
wheel                     0.37.1             pyhd3eb1b0_0
xz                        5.2.5                h7b6447c_0
yaml                      0.2.5                h7b6447c_0
zlib                      1.2.12               h7f8727e_1
zstd                      1.5.0                ha95c52a_0    conda-forge

And this is the environment info:

     active environment : base
    active env location : /opt/conda
            shell level : 1
       user config file : /root/.condarc
 populated config files :
          conda version : 4.13.0
    conda-build version : not installed
         python version : 3.9.12.final.0
       virtual packages : __linux=5.10.16.3=0
                          __glibc=2.31=0
                          __unix=0=0
                          __archspec=1=x86_64
       base environment : /opt/conda  (writable)
      conda av data dir : /opt/conda/etc/conda
  conda av metadata url : None
           channel URLs : https://repo.anaconda.com/pkgs/main/linux-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/r/linux-64
                          https://repo.anaconda.com/pkgs/r/noarch
          package cache : /opt/conda/pkgs
                          /root/.conda/pkgs
       envs directories : /opt/conda/envs
                          /root/.conda/envs
               platform : linux-64
             user-agent : conda/4.13.0 requests/2.27.1 CPython/3.9.12 Linux/5.10.16.3-microsoft-standard-WSL2 debian/11 glibc/2.31
                UID:GID : 0:0
             netrc file : None
           offline mode : False
minrk commented 2 years ago

Have you activated the env? The compiler packages set $CXX, $CC, and friends on environment activation. If you just installed fenics in the base env, try: conda activate base.

RemDelaporteMathurin commented 2 years ago

try: conda activate base.

I ran conda activate base but got the following error:

CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.
To initialize your shell, run

    $ conda init <SHELL_NAME>

Currently supported shells are:
  - bash
  - fish
  - tcsh
  - xonsh
  - zsh
  - powershell

See 'conda init --help' for more information and options.

IMPORTANT: You may need to close and restart your shell after running 'conda init'.

Also, when I run this environment (docker image + conda install fenics) in Windows, everything works fine and I don't need to do anything to run fenics

minrk commented 2 years ago

I don't know what's different about your Windows and other docker environment, but that lack of conda init is definitely the key. I'm not sure if it's how the image is being invoked, or if CMD/ENTRYPOINT are being overridden. A complete example of what's being built/run may help.

You can re-enable the conda command with:

source $PREFIX/etc/profile.d/conda.sh
conda activate base

If you're installing from conda-forge, I might also recommend using the condaforge/mambaforge image. It'll be a bit quicker/lighter since it won't have to replace things from the anaconda channel with the same packages from conda-forge.

minrk commented 2 years ago

Note that the profile.d/conda.sh will only be run by default for interactive shell sessions, but not noninteractive ones. So you may see a difference between:

$ docker run --rm -it my-image bash
[image prompt] $ python fenics-script.py # OK
$ docker run --rm -it my-image python fenics-script.py # No such file or directory: 'c++' 

Ensuring you alwasy invoke an interactive shell:

$ docker run --rm -it my-image bash -i -c "python fenics-script.py"

is one way to ensure the shell is fully set up

RemDelaporteMathurin commented 2 years ago

Right so here's what i'm building:

My Dockerfile:

FROM continuumio/miniconda3

RUN conda install -c conda-forge fenics

RUN pip install festim matplotlib meshio[all] ipykernel h-transport-materials==0.4.0

I run it locally with

docker build . -t festim-workshop
docker run -ti festim-workshop

Then just to test the implementation I run:

python -c "import fenics as f; mesh = f.UnitSquareMesh(3, 3);V = f.FunctionSpace(mesh, 'P', 1)"

Locally, everything works fine (no conda init or anything).

What I'm trying to do is having this run in GitHub actions for CI.

My workflow file

jobs:

  build:

    runs-on: ubuntu-latest
    container: remdelaportemathurin/festim-workshop  # built from the Dockerfile above

    steps:

      - uses: actions/checkout@v2

      - name: Test fenics
        run : |
          python -c "import fenics as f; mesh = f.UnitSquareMesh(3, 3);V = f.FunctionSpace(mesh, 'P', 1)"

This last step produces this error message:

Run python -c "import fenics as f; mesh = f.UnitSquareMesh(3, 3);V = f.FunctionSpace(mesh, 'P', 1)"
Calling FFC just-in-time (JIT) compiler, this may take some time.
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/opt/conda/lib/python3.9/site-packages/dolfin/function/functionspace.py", line 33, in __init__
    self._init_convenience(*args, **kwargs)
  File "/opt/conda/lib/python3.9/site-packages/dolfin/function/functionspace.py", line 100, in _init_convenience
    self._init_from_ufl(mesh, element, constrained_domain=constrained_domain)
  File "/opt/conda/lib/python3.9/site-packages/dolfin/function/functionspace.py", line [4](https://github.com/RemDelaporteMathurin/FESTIM-workshop/runs/7745477951?check_suite_focus=true#step:4:5)2, in _init_from_ufl
    ufc_element, ufc_dofmap = ffc_jit(element, form_compiler_parameters=None,
  File "/opt/conda/lib/python3.9/site-packages/dolfin/jit/jit.py", line 47, in mpi_jit
    return local_jit(*args, **kwargs)
  File "/opt/conda/lib/python3.9/site-packages/dolfin/jit/jit.py", line 97, in ffc_jit
    return ffc.jit(ufl_form, parameters=p)
  File "/opt/conda/lib/python3.9/site-packages/ffc/jitcompiler.py", line 217, in jit
    module = jit_build(ufl_object, module_name, parameters)
  File "/opt/conda/lib/python3.9/site-packages/ffc/jitcompiler.py", line 130, in jit_build
    module, signature = dijitso.jit(jitable=ufl_object,
  File "/opt/conda/lib/python3.9/site-packages/dijitso/jit.py", line 177, in jit
    build_shared_library(signature, header, source, dependencies,
  File "/opt/conda/lib/python3.9/site-packages/dijitso/build.py", line 1[5](https://github.com/RemDelaporteMathurin/FESTIM-workshop/runs/7745477951?check_suite_focus=true#step:4:6)3, in build_shared_library
    status, output = get_status_output(cmd)
  File "/opt/conda/lib/python3.9/site-packages/dijitso/system.py", line 40, in _get_status_output_subprocess
    pipe = subprocess.Popen(cmd, shell=False, cwd=cwd, env=env,
  File "/opt/conda/lib/python3.9/subprocess.py", line 951, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/opt/conda/lib/python3.9/subprocess.py", line 1[8](https://github.com/RemDelaporteMathurin/FESTIM-workshop/runs/7745477951?check_suite_focus=true#step:4:9)[21](https://github.com/RemDelaporteMathurin/FESTIM-workshop/runs/7745477951?check_suite_focus=true#step:4:22), in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'c++'
Error: Process completed with exit code 1.

When I add conda init bash and conda activate base, the workflow file looks like this:

jobs:
  build:

    runs-on: ubuntu-latest
    container: remdelaportemathurin/festim-workshop

    steps:
      - uses: actions/checkout@v2

      - name: Conda init
        run : conda init bash

      - name: Test fenics
        run : |
          conda activate base
          python -c "import fenics as f; mesh = f.UnitSquareMesh(3, 3);V = f.FunctionSpace(mesh, 'P', 1)"

I get the following error in GA:

Run conda activate base

CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.
To initialize your shell, run

    $ conda init <SHELL_NAME>

Currently supported shells are:
  - bash
  - fish
  - tcsh
  - xonsh
  - zsh
  - powershell

See 'conda init --help' for more information and options.

IMPORTANT: You may need to close and restart your shell after running 'conda init'.

Error: Process completed with exit code 1.

The complete workflow can be found here

RemDelaporteMathurin commented 2 years ago

Note that the profile.d/conda.sh will only be run by default for interactive shell sessions, but not noninteractive ones. So you may see a difference between:

$ docker run --rm -it my-image bash
[image prompt] $ python fenics-script.py # OK
$ docker run --rm -it my-image python fenics-script.py # No such file or directory: 'c++' 

Ensuring you alwasy invoke an interactive shell:

$ docker run --rm -it my-image bash -i -c "python fenics-script.py"

is one way to ensure the shell is fully set up

Thanks for this tip. The problem is I use this image in a Github actions workflow so I don't really know how to do that :-/

minrk commented 2 years ago

Add:

defaults:
  run:
    # ensure base env is activated when running commands
    shell: bash -eo pipefail -c "source /opt/conda/etc/profile.d/conda.sh; conda activate base; source {0}"

to your workflow file. This will ensure the conda env is activated before each run command.

RemDelaporteMathurin commented 2 years ago

Yep that fixed it! Thank you very much @minrk