Cannot import dolfinx on Mac M2

Hello everyone,
I can’t import dolfinx on Python (3.12.7) after an installation via Conda. I have a Mac M2 (Sonoma 14.6.1).

I used this commands:

conda create -n fenicsx
conda activate fenicsx
conda install -c conda-forge fenics-dolfinx mpich pyvista

Here is the full error:
(fenicsx) rogalski@mbpdenirogalski ~ % python3 -c ‘import dolfinx’
Traceback (most recent call last):
File “”, line 1, in
import dolfinx
File “/opt/miniconda3/envs/fenicsx/lib/python3.13/site-packages/dolfinx/init.py”, line 30, in
from dolfinx import common
File “/opt/miniconda3/envs/fenicsx/lib/python3.13/site-packages/dolfinx/common.py”, line 11, in
from dolfinx import cpp as _cpp
ImportError: dlopen(/opt/miniconda3/envs/fenicsx/lib/python3.13/site-packages/dolfinx/cpp.cpython-313-darwin.so, 0x0002): Library not loaded: /Users/runner/miniforge3/conda-bld/slepc_1730380344949/work/installed-arch-darwin-c-opt/lib/libslepc.3.22.dylib
Referenced from: <596FF3AB-6C79-3DBD-9109-248D184FAE6D> /opt/miniconda3/envs/fenicsx/lib/libdolfinx.0.9.0.dylib
Reason: tried: ‘/Users/runner/miniforge3/conda-bld/slepc_1730380344949/work/installed-arch-darwin-c-opt/lib/libslepc.3.22.dylib’ (no such file), ‘/System/Volumes/Preboot/Cryptexes/OS/Users/runner/miniforge3/conda-bld/slepc_1730380344949/work/installed-arch-darwin-c-opt/lib/libslepc.3.22.dylib’ (no such file), ‘/Users/runner/miniforge3/conda-bld/slepc_1730380344949/work/installed-arch-darwin-c-opt/lib/libslepc.3.22.dylib’ (no such file), ‘/usr/local/lib/libslepc.3.22.dylib’ (no such file), ‘/usr/lib/libslepc.3.22.dylib’ (no such file, not in dyld cache)

Can you help me solve this?

Thank you in advance for your help!

I’ll have a look. Seems like there might be something wrong with the slepc build.

Can you share the output of conda env export?

1 Like

Thank you very much for the answer.

Here is the output:

(fenicsx) rogalski@mbpdenirogalski ~ % conda env export
name: fenicsx
channels:
  - conda-forge
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
dependencies:
  - aiohappyeyeballs=2.4.3=pyhd8ed1ab_0
  - aiohttp=3.10.10=py313h9c6a887_0
  - aiosignal=1.3.1=pyhd8ed1ab_0
  - aom=3.9.1=h7bae524_0
  - attrs=24.2.0=pyh71513ae_0
  - blosc=1.21.6=h5499902_0
  - brotli=1.1.0=hd74edd7_2
  - brotli-bin=1.1.0=hd74edd7_2
  - brotli-python=1.1.0=py313h3579c5c_2
  - bzip2=1.0.8=h99b78c6_7
  - c-ares=1.34.2=h7ab814d_0
  - c-blosc2=2.15.1=h5063078_0
  - ca-certificates=2024.8.30=hf0a4a13_0
  - cairo=1.18.0=hb4a6bf7_3
  - cctools_osx-arm64=1010.6=hfaac078_1
  - certifi=2024.8.30=pyhd8ed1ab_0
  - cffi=1.17.1=py313hc845a76_0
  - charset-normalizer=3.4.0=pyhd8ed1ab_0
  - clang=18.1.8=default_h675cc0c_5
  - clang-18=18.1.8=default_h5c12605_5
  - clang_impl_osx-arm64=18.1.8=h2ae9ea5_21
  - clang_osx-arm64=18.1.8=h54d7cd3_21
  - clangxx=18.1.8=default_h675cc0c_5
  - compiler-rt=18.1.8=h856b3c1_1
  - compiler-rt_osx-arm64=18.1.8=h832e737_1
  - contourpy=1.3.0=py313hc846e5e_2
  - cycler=0.12.1=pyhd8ed1ab_0
  - cyrus-sasl=2.1.27=h60b93bd_7
  - dav1d=1.2.1=hb547adb_0
  - double-conversion=3.3.0=h13dd4ca_0
  - eigen=3.4.0=h1995070_0
  - expat=2.6.3=hf9b8971_0
  - fenics-basix=0.9.0=py313hd7981f8_2
  - fenics-basix-nanobind-abi=0.2.1.18=h9b63b7c_2
  - fenics-dolfinx=0.9.0=py313hb8db8a6_105
  - fenics-ffcx=0.9.0=pyh2e48890_0
  - fenics-libbasix=0.9.0=hf7ae0cd_2
  - fenics-libdolfinx=0.9.0=ha5ec493_105
  - fenics-ufcx=0.9.0=hb7f7608_0
  - fenics-ufl=2024.2.0=pyhd8ed1ab_0
  - ffmpeg=7.1.0=gpl_hd730352_103
  - fftw=3.3.10=mpi_mpich_hd148bab_10
  - fmt=11.0.2=h420ef59_0
  - font-ttf-dejavu-sans-mono=2.37=hab24e00_0
  - font-ttf-inconsolata=3.000=h77eed37_0
  - font-ttf-source-code-pro=2.038=h77eed37_0
  - font-ttf-ubuntu=0.83=h77eed37_3
  - fontconfig=2.15.0=h1383a14_1
  - fonts-conda-ecosystem=1=0
  - fonts-conda-forge=1=0
  - fonttools=4.54.1=py313heb2b014_1
  - freetype=2.12.1=hadb7bae_2
  - fribidi=1.0.10=h27ca646_0
  - frozenlist=1.5.0=py313h63a2874_0
  - gdk-pixbuf=2.42.12=h7ddc832_0
  - gl2ps=1.4.2=hc97c1ff_1
  - glew=2.1.0=h9f76cd9_2
  - gmp=6.3.0=h7bae524_2
  - graphite2=1.3.13=hebf3989_1003
  - h2=4.1.0=pyhd8ed1ab_0
  - harfbuzz=9.0.0=h997cde5_1
  - hdf4=4.2.15=h2ee6834_7
  - hdf5=1.14.4=mpi_mpich_h37ba8a5_1
  - hpack=4.0.0=pyh9f0ad1d_0
  - hyperframe=6.0.1=pyhd8ed1ab_0
  - hypre=2.32.0=mpi_mpich_h189fe77_1
  - icu=75.1=hfee45f7_0
  - idna=3.10=pyhd8ed1ab_0
  - jsoncpp=1.9.6=h7b3277c_0
  - kahip=3.16=py313hb16cd43_4
  - kiwisolver=1.4.7=py313hf9c7212_0
  - krb5=1.21.3=h237132a_0
  - lame=3.100=h1a8c8d9_1003
  - lcms2=2.16=ha0e7c42_0
  - ld64_osx-arm64=951.9=hdd277f2_1
  - lerc=4.0.0=h9a09cb3_0
  - libabseil=20240722.0=cxx17_hf9b8971_1
  - libadios2=2.10.2=mpi_mpich_h91f8644_0
  - libaec=1.1.3=hebf3989_0
  - libass=0.17.3=hf20b609_0
  - libblas=3.9.0=25_osxarm64_openblas
  - libboost=1.86.0=h29978a0_2
  - libboost-devel=1.86.0=hf450f58_2
  - libboost-headers=1.86.0=hce30654_2
  - libbrotlicommon=1.1.0=hd74edd7_2
  - libbrotlidec=1.1.0=hd74edd7_2
  - libbrotlienc=1.1.0=hd74edd7_2
  - libcblas=3.9.0=25_osxarm64_openblas
  - libclang-cpp17=17.0.6=default_h146c034_7
  - libclang-cpp18.1=18.1.8=default_h5c12605_5
  - libclang13=19.1.3=default_h5f28f6d_0
  - libcurl=8.10.1=h13a7ad3_0
  - libcxx=19.1.3=ha82da77_0
  - libcxx-devel=18.1.8=h6dc3340_7
  - libdeflate=1.22=hd74edd7_0
  - libedit=3.1.20191231=hc8eb9b7_2
  - libev=4.33=h93a5062_2
  - libexpat=2.6.3=hf9b8971_0
  - libffi=3.4.2=h3422bc3_5
  - libgfortran=5.0.0=13_2_0_hd922786_3
  - libgfortran5=13.2.0=hf226fd6_3
  - libglib=2.82.2=h07bd6cf_0
  - libhwloc=2.11.2=default_h3f80f97_1000
  - libiconv=1.17=h0d3ecfb_2
  - libintl=0.22.5=h8414b35_3
  - libjpeg-turbo=3.0.0=hb547adb_1
  - liblapack=3.9.0=25_osxarm64_openblas
  - libllvm17=17.0.6=h5090b49_2
  - libllvm18=18.1.8=h5090b49_2
  - libllvm19=19.1.3=haf57ff0_0
  - libmpdec=4.0.0=h99b78c6_0
  - libnetcdf=4.9.2=nompi_h853a48d_115
  - libnghttp2=1.64.0=h6d7220d_0
  - libntlm=1.4=h3422bc3_1002
  - libogg=1.3.5=h99b78c6_0
  - libopenblas=0.3.28=openmp_h8b6c093_0
  - libopenvino=2024.4.0=hbfeda7a_2
  - libopenvino-arm-cpu-plugin=2024.4.0=hbfeda7a_2
  - libopenvino-auto-batch-plugin=2024.4.0=hf276634_2
  - libopenvino-auto-plugin=2024.4.0=hf276634_2
  - libopenvino-hetero-plugin=2024.4.0=h03892cd_2
  - libopenvino-ir-frontend=2024.4.0=h03892cd_2
  - libopenvino-onnx-frontend=2024.4.0=h7f5a098_2
  - libopenvino-paddle-frontend=2024.4.0=h7f5a098_2
  - libopenvino-pytorch-frontend=2024.4.0=h5833ebf_2
  - libopenvino-tensorflow-frontend=2024.4.0=h9d544f2_2
  - libopenvino-tensorflow-lite-frontend=2024.4.0=h5833ebf_2
  - libopus=1.3.1=h27ca646_1
  - libpng=1.6.44=hc14010f_0
  - libpq=17.0=h9fd3c6c_4
  - libprotobuf=5.28.2=h8f0b736_0
  - libptscotch=7.0.5=he82f32e_2
  - librsvg=2.58.4=h40956f1_0
  - libscotch=7.0.5=h9f781f6_2
  - libsodium=1.0.20=h99b78c6_0
  - libsqlite=3.47.0=hbaaea75_1
  - libssh2=1.11.0=h7a5bd25_0
  - libtheora=1.1.1=h99b78c6_1006
  - libtiff=4.7.0=hfce79cd_1
  - libvorbis=1.3.7=h9f76cd9_0
  - libvpx=1.14.1=h7bae524_0
  - libwebp-base=1.4.0=h93a5062_0
  - libxcb=1.17.0=hdb1d25a_0
  - libxml2=2.13.4=h8424949_2
  - libzip=1.11.2=h1336266_0
  - libzlib=1.3.1=h8359307_2
  - llvm-openmp=19.1.3=hb52a8e5_0
  - llvm-tools=18.1.8=h5090b49_2
  - llvm-tools-18=18.1.8=h5090b49_2
  - loguru=0.7.2=py313h8f79df9_2
  - lz4-c=1.9.4=hb7217d7_0
  - matplotlib-base=3.9.2=py313h3f078ce_1
  - metis=5.1.0=h15f6cfe_1007
  - mpfr=4.2.1=hb693164_3
  - mpi=1.0.1=mpich
  - mpi4py=4.0.1=py313h41ff552_0
  - mpich=4.2.3=he5dbaa7_100
  - msgpack-python=1.1.0=py313hf9c7212_0
  - multidict=6.1.0=py313h6347b5a_1
  - mumps-include=5.7.3=hce30654_5
  - mumps-mpi=5.7.3=h83d4000_5
  - munkres=1.1.4=pyh9f0ad1d_0
  - mysql-common=9.0.1=h0887d5e_2
  - mysql-libs=9.0.1=he9bc4e1_2
  - ncurses=6.5=h7bae524_1
  - nlohmann_json=3.11.3=h00cdb27_1
  - numpy=2.1.3=py313hca4752e_0
  - openh264=2.4.1=hebf3989_0
  - openjpeg=2.5.2=h9f1df11_0
  - openldap=2.6.8=h50f2afc_0
  - openssl=3.3.2=h8359307_0
  - packaging=24.1=pyhd8ed1ab_0
  - pango=1.54.0=h9ee27a3_2
  - parmetis=4.0.3=ha4b917a_1007
  - pcre2=10.44=h297a79d_2
  - petsc=3.22.1=real_hda3b05f_101
  - petsc4py=3.22.1=py313h712231a_0
  - pillow=11.0.0=py313h97432e1_0
  - pip=24.3.1=pyh145f28c_0
  - pixman=0.43.4=hebf3989_0
  - pkg-config=0.29.2=hde07d2e_1009
  - platformdirs=4.3.6=pyhd8ed1ab_0
  - pooch=1.8.2=pyhd8ed1ab_0
  - proj=9.5.0=h61a8e3e_0
  - propcache=0.2.0=py313h20a7fcf_2
  - pthread-stubs=0.4=hd74edd7_1002
  - pugixml=1.14=h13dd4ca_0
  - pycparser=2.22=pyhd8ed1ab_0
  - pyparsing=3.2.0=pyhd8ed1ab_1
  - pysocks=1.7.1=pyha2e5f31_6
  - python=3.13.0=h75c3a9f_100_cp313
  - python-dateutil=2.9.0=pyhd8ed1ab_0
  - python_abi=3.13=5_cp313
  - pyvista=0.44.1=pyhd8ed1ab_0
  - qhull=2020.2=h420ef59_5
  - qt6-main=6.7.3=h2fbab7f_1
  - readline=8.2=h92ec313_1
  - requests=2.32.3=pyhd8ed1ab_0
  - scalapack=2.2.0=h71a4f75_4
  - scooby=0.10.0=pyhd8ed1ab_0
  - setuptools=75.3.0=pyhd8ed1ab_0
  - sigtool=0.1.3=h44b9a77_0
  - six=1.16.0=pyh6c4a22f_0
  - slepc=3.22.1=real_hf0b33f3_300
  - slepc4py=3.22.1=py313h3bb7f59_0
  - snappy=1.2.1=hd02b534_0
  - spdlog=1.14.1=h6d8af72_1
  - sqlite=3.47.0=hcd14bea_1
  - suitesparse=7.8.3=hcefb574_0
  - superlu=5.2.2=hc615359_0
  - superlu_dist=9.0.0=h2cb61f8_1
  - svt-av1=2.3.0=hf24288c_0
  - tapi=1300.6.5=h03f4b80_0
  - tbb=2022.0.0=h0cbf7ec_0
  - tbb-devel=2022.0.0=h6e261d1_0
  - tk=8.6.13=h5083fa2_1
  - typing-extensions=4.12.2=hd8ed1ab_0
  - typing_extensions=4.12.2=pyha770c72_0
  - tzdata=2024b=hc8b5060_0
  - urllib3=2.2.3=pyhd8ed1ab_0
  - utfcpp=4.0.6=h54c0426_0
  - vtk=9.3.1=qt_py313h8d5bf7a_209
  - vtk-base=9.3.1=qt_py313hc8fffa2_209
  - vtk-io-ffmpeg=9.3.1=qt_py313hf99a90b_209
  - wslink=2.2.1=pyhd8ed1ab_0
  - x264=1!164.3095=h57fd34a_2
  - x265=3.5=hbc6ce65_3
  - xorg-libxau=1.0.11=hd74edd7_1
  - xorg-libxdmcp=1.1.5=hd74edd7_0
  - xz=5.2.6=h57fd34a_0
  - yaml=0.2.5=h3422bc3_2
  - yarl=1.16.0=py313h63a2874_0
  - zeromq=4.3.5=h9f5b81c_6
  - zfp=0.5.5=hcfdfaf5_8
  - zlib=1.3.1=h8359307_2
  - zlib-ng=2.2.2=hf9b8971_0
  - zstandard=0.23.0=py313hf2da073_1
  - zstd=1.5.6=hb46c0d2_0
prefix: /opt/miniconda3/envs/fenicsx
(fenicsx) rogalski@mbpdenirogalski ~ %

it is a problem in the latest build of slepc that caused the latest dolfinx (build 105) to have incorrect linkage to slepc, which slipped through because of the minimal amount of testing the cross-compiled builds can get on conda-forge. This has been fixed, so once build 106 of dolfinx is available, you should be able to get it with conda upgrade fenics-dolfinx. It should be available within an hour or two. In the meantime, build 104 should not have this problem:

conda install 'fenics-dolfinx=0.9.0=*_104'
1 Like