Duplicate LC_RPATH errors on macOS 15.4 Sequoia

After upgrading to macOS 15.4 recently, I am not able to run fenicsx-based codes. I get a lot of dlopen errors regarding duplicate LC_RPATH entries. I installed via conda originally.

**ImportError** : dlopen(/Users/bosmacs/.cache/fenics/libffcx_forms_2776970e29d8246dcb3b0507cb5e1b1509b9e159.cpython-313-darwin.so, 0x0002): tried: '/Users/bosmacs/.cache/fenics/libffcx_forms_2776970e29d8246dcb3b0507cb5e1b1509b9e159.cpython-313-darwin.so' (duplicate LC_RPATH '/Users/bosmacs/Repos/dh-solver/.pixi/envs/default/lib'), '/System/Volumes/Preboot/Cryptexes/OS/Users/bosmacs/.cache/fenics/libffcx_forms_2776970e29d8246dcb3b0507cb5e1b1509b9e159.cpython-313-darwin.so' (no such file), '/Users/bosmacs/.cache/fenics/libffcx_forms_2776970e29d8246dcb3b0507cb5e1b1509b9e159.cpython-313-darwin.so' (duplicate LC_RPATH '/Users/bosmacs/Repos/dh-solver/.pixi/envs/default/lib')

Removing the .cache/fenics folder does not seem to help, they are simply regenerated. I can confirm with otool that there are duplicate entries:

otool -l ~/.cache/fenics/libffcx_forms_2776970e29d8246dcb3b0507cb5e1b1509b9e159.cpython-313-darwin.so | grep -A3 LC_RPATH
          cmd LC_RPATH
      cmdsize 72
         path /Users/bosmacs/Repos/dh-solver/.pixi/envs/default/lib (offset 12)
Load command 12
          cmd LC_RPATH
      cmdsize 72
         path /Users/bosmacs/Repos/dh-solver/.pixi/envs/default/lib (offset 12)
Load command 13
          cmd LC_RPATH
      cmdsize 72
         path /Users/bosmacs/Repos/dh-solver/.pixi/envs/default/lib (offset 12)
Load command 14

Looks like the issue may stem from Xcode 16.3. I installed 16.2 and set the command line tools to the 16.2 version, and am able to run again.

conda-forge folks are working on a fix, but it should work to patch your libgfortran with this script:

import os
from subprocess import run

import lief


def patch(path):
    fat = lief.MachO.parse(path)
    thin = fat.take(lief.MachO.CPU_TYPES.ARM64)
    thin.commands[9].sdk = [11, 0, 0]
    thin.write(path)
    run(["codesign", "-f", "-s", "-", path], check=True)


prefix_lib = os.path.join(os.environ["CONDA_PREFIX"], "lib")

for libname in [
    "libgfortran.5.dylib",
    "libquadmath.0.dylib",
]:
    lib_path = os.path.join(prefix_lib, libname)
    print(f"Patching {lib_path}")
    patch(lib_path)

(requires py-lief=0.14.*)

WARNING: be prepared to recreate your env if patching any libraries like this

Thanks! Forgot to mention I had the same issue with libgfortran, and fixed in a similar manner, with

install_name_tool -delete_rpath "@loader_path" /path/to/libgfortran.dylib

and re-signing with codesign. Your script simplifies the process.

What I was pointing out is the same problem appears with dylibs generated by just-in-time compilations of FFCX forms, it appears.

I’m having the same issue after updating to macOS 15.4. I was able to patch libgfortran with a batch script that I found here: https://github.com/conda-forge/numpy-feedstock/issues/347#issuecomment-2746317575, but the problem persist with dylibs generated by just-in-time compilations of FFCX forms.

Yes, I’ve just discovered the same problem applies to ffcx outputs because rpaths are duplicated from Python’s LDSHARED and the default $LDFLAGS. That makes removing them more complex. I believe you can fix it by setting the $LDSHARED environment variable:

export LDSHARED="$CC -bundle -undefined dynamic_lookup"

which has some duplicate -Wl,-rpath entries by default (see sysconfig.get_config_var("LDSHARED").

This won’t affect cached builds, so you’ll need to either clear your cache or patch cached files in-place with a script like this one.

1 Like

status update:

  • libgfortran is fixed if you have libgfortran5=14.* This should be the default for most folks with recently updated or created envs, but if your env hasn’t had an update in a while, conda update libgfortran5 should do it
  • The linker has been fixed to turn these duplicate rpaths into warnings (as the new default Apple linker has been doing since xcode 15), so if you update ld64 to at least build 6 (ld64=951.9=h4c6efb1_6 on mac arm)

So in short, an env should be fixed with:

mamba update libgfortran5 ld64

without needing to patch anything. You may need to clean your ffcx cache.

Thanks, cleaning the cache and updating the packages finally solved my problem.
(I needed to force the ld64 version in the update command to make it work.)

Hello everyone. I’m facing the same problem exposed here since the update of Sequoia. The code proposed by @minrk

import os
from subprocess import run

import lief


def patch(path):
    fat = lief.MachO.parse(path)
    thin = fat.take(lief.MachO.CPU_TYPES.ARM64)
    thin.commands[9].sdk = [11, 0, 0]
    thin.write(path)
    run(["codesign", "-f", "-s", "-", path], check=True)


prefix_lib = os.path.join(os.environ["CONDA_PREFIX"], "lib")

for libname in [
    "libgfortran.5.dylib",
    "libquadmath.0.dylib",
]:
    lib_path = os.path.join(prefix_lib, libname)
    print(f"Patching {lib_path}")
    patch(lib_path)

returns me this error :

Patching /opt/anaconda3/envs/env3-10-complex/lib/libgfortran.5.dylib
The export trie don't fit in the allocated space
/opt/anaconda3/envs/env3-10-complex/lib/libgfortran.5.dylib: invalid or unsupported format for signature
Traceback (most recent call last):
  File "/Users/pierremariotti/Documents/PhD/FEniCSx/new_try2/root/ABC_FEniCSx_classical/solve_ffcx.py", line 23, in <module>
    patch(lib_path)
  File "/Users/pierremariotti/Documents/PhD/FEniCSx/new_try2/root/ABC_FEniCSx_classical/solve_ffcx.py", line 12, in patch
    run(["codesign", "-f", "-s", "-", path], check=True)
  File "/opt/anaconda3/envs/env3-10-complex/lib/python3.10/subprocess.py", line 526, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['codesign', '-f', '-s', '-', '/opt/anaconda3/envs/env3-10-complex/lib/libgfortran.5.dylib']' returned non-zero exit status 1.

Knowing that I build my conda environment from the following line :

conda create -n env3-10-complex -c conda-forge python=3.10 fenics-dolfinx 'petsc=*=complex*' mpich

Thanks for your help.

if your env is up-to-date, no patches are needed. So as long as you do mamba update libgfortran5 ld64 it should be resolved. If it’s not make sure to clear your ffcx cache and share conda env export.

I re-create my env just now, I installed mamba, executed mamba update libgfortran5 ld64, and removed the cache with rm -rf ~/.cache/fenics. I’m still facing the super long error, that I give you again, followed by the result of conda env export :

(env3-10-complex) pierremariotti@arm64-apple-darwin20 ABC_FEniCSx_classical % python test_oldABCnewVn.py                                                                        
Traceback (most recent call last):
  File "/opt/anaconda3/envs/env3-10-complex/lib/python3.10/site-packages/numpy/_core/__init__.py", line 23, in <module>
    from . import multiarray
  File "/opt/anaconda3/envs/env3-10-complex/lib/python3.10/site-packages/numpy/_core/multiarray.py", line 10, in <module>
    from . import overrides
  File "/opt/anaconda3/envs/env3-10-complex/lib/python3.10/site-packages/numpy/_core/overrides.py", line 7, in <module>
    from numpy._core._multiarray_umath import (
ImportError: dlopen(/opt/anaconda3/envs/env3-10-complex/lib/python3.10/site-packages/numpy/_core/_multiarray_umath.cpython-310-darwin.so, 0x0002): Library not loaded: @rpath/libgfortran.5.dylib
  Referenced from: <CAA510D4-816A-34E5-9021-485EF5D56159> /opt/anaconda3/envs/env3-10-complex/lib/libopenblas.0.dylib
  Reason: tried: '/opt/anaconda3/envs/env3-10-complex/lib/libgfortran.5.dylib' (code signature invalid in <C739582F-D95B-303A-9F86-7B43C361ECC7> '/opt/anaconda3/envs/env3-10-complex/lib/libgfortran.5.dylib' (errno=85) sliceOffset=0x00000000, codeBlobOffset=0x001BC120, codeBlobSize=0x00003C90), '/opt/anaconda3/envs/env3-10-complex/lib/libgfortran.5.dylib' (code signature invalid in <C739582F-D95B-303A-9F86-7B43C361ECC7> '/opt/anaconda3/envs/env3-10-complex/lib/libgfortran.5.dylib' (errno=85) sliceOffset=0x00000000, codeBlobOffset=0x001BC120, codeBlobSize=0x00003C90), '/opt/anaconda3/envs/env3-10-complex/lib/python3.10/site-packages/numpy/_core/../../../../libgfortran.5.dylib' (code signature invalid in <C739582F-D95B-303A-9F86-7B43C361ECC7> '/opt/anaconda3/envs/env3-10-complex/lib/libgfortran.5.dylib' (errno=85) sliceOffset=0x00000000, codeBlobOffset=0x001BC120, codeBlobSize=0x00003C90), '/opt/anaconda3/envs/env3-10-complex/lib/python3.10/site-packages/numpy/_core/../../../../libgfortran.5.dylib' (code signature invalid in <C739582F-D95B-303A-9F86-7B43C361ECC7> '/opt/anaconda3/envs/env3-10-complex/lib/libgfortran.5.dylib' (errno=85) sliceOffset=0x00000000, codeBlobOffset=0x001BC120, codeBlobSize=0x00003C90), '/opt/anaconda3/envs/env3-10-complex/bin/../lib/libgfortran.5.dylib' (code signature invalid in <C739582F-D95B-303A-9F86-7B43C361ECC7> '/opt/anaconda3/envs/env3-10-complex/lib/libgfortran.5.dylib' (errno=85) sliceOffset=0x00000000, codeBlobOffset=0x001BC120, codeBlobSize=0x00003C90), '/opt/anaconda3/envs/env3-10-complex/bin/../lib/libgfortran.5.dylib' (code signature invalid in <C739582F-D95B-303A-9F86-7B43C361ECC7> '/opt/anaconda3/envs/env3-10-complex/lib/libgfortran.5.dylib' (errno=85) sliceOffset=0x00000000, codeBlobOffset=0x001BC120, codeBlobSize=0x00003C90), '/usr/local/lib/libgfortran.5.dylib' (no such file), '/usr/lib/libgfortran.5.dylib' (no such file, not in dyld cache)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/anaconda3/envs/env3-10-complex/lib/python3.10/site-packages/numpy/__init__.py", line 114, in <module>
    from numpy.__config__ import show_config
  File "/opt/anaconda3/envs/env3-10-complex/lib/python3.10/site-packages/numpy/__config__.py", line 4, in <module>
    from numpy._core._multiarray_umath import (
  File "/opt/anaconda3/envs/env3-10-complex/lib/python3.10/site-packages/numpy/_core/__init__.py", line 49, in <module>
    raise ImportError(msg)
ImportError: 

IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!

Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.

We have compiled some common reasons and troubleshooting tips at:

    https://numpy.org/devdocs/user/troubleshooting-importerror.html

Please note and check the following:

  * The Python version is: Python3.10 from "/opt/anaconda3/envs/env3-10-complex/bin/python"
  * The NumPy version is: "2.2.5"

and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.

Original error was: dlopen(/opt/anaconda3/envs/env3-10-complex/lib/python3.10/site-packages/numpy/_core/_multiarray_umath.cpython-310-darwin.so, 0x0002): Library not loaded: @rpath/libgfortran.5.dylib
  Referenced from: <CAA510D4-816A-34E5-9021-485EF5D56159> /opt/anaconda3/envs/env3-10-complex/lib/libopenblas.0.dylib
  Reason: tried: '/opt/anaconda3/envs/env3-10-complex/lib/libgfortran.5.dylib' (code signature invalid in <C739582F-D95B-303A-9F86-7B43C361ECC7> '/opt/anaconda3/envs/env3-10-complex/lib/libgfortran.5.dylib' (errno=85) sliceOffset=0x00000000, codeBlobOffset=0x001BC120, codeBlobSize=0x00003C90), '/opt/anaconda3/envs/env3-10-complex/lib/libgfortran.5.dylib' (code signature invalid in <C739582F-D95B-303A-9F86-7B43C361ECC7> '/opt/anaconda3/envs/env3-10-complex/lib/libgfortran.5.dylib' (errno=85) sliceOffset=0x00000000, codeBlobOffset=0x001BC120, codeBlobSize=0x00003C90), '/opt/anaconda3/envs/env3-10-complex/lib/python3.10/site-packages/numpy/_core/../../../../libgfortran.5.dylib' (code signature invalid in <C739582F-D95B-303A-9F86-7B43C361ECC7> '/opt/anaconda3/envs/env3-10-complex/lib/libgfortran.5.dylib' (errno=85) sliceOffset=0x00000000, codeBlobOffset=0x001BC120, codeBlobSize=0x00003C90), '/opt/anaconda3/envs/env3-10-complex/lib/python3.10/site-packages/numpy/_core/../../../../libgfortran.5.dylib' (code signature invalid in <C739582F-D95B-303A-9F86-7B43C361ECC7> '/opt/anaconda3/envs/env3-10-complex/lib/libgfortran.5.dylib' (errno=85) sliceOffset=0x00000000, codeBlobOffset=0x001BC120, codeBlobSize=0x00003C90), '/opt/anaconda3/envs/env3-10-complex/bin/../lib/libgfortran.5.dylib' (code signature invalid in <C739582F-D95B-303A-9F86-7B43C361ECC7> '/opt/anaconda3/envs/env3-10-complex/lib/libgfortran.5.dylib' (errno=85) sliceOffset=0x00000000, codeBlobOffset=0x001BC120, codeBlobSize=0x00003C90), '/opt/anaconda3/envs/env3-10-complex/bin/../lib/libgfortran.5.dylib' (code signature invalid in <C739582F-D95B-303A-9F86-7B43C361ECC7> '/opt/anaconda3/envs/env3-10-complex/lib/libgfortran.5.dylib' (errno=85) sliceOffset=0x00000000, codeBlobOffset=0x001BC120, codeBlobSize=0x00003C90), '/usr/local/lib/libgfortran.5.dylib' (no such file), '/usr/lib/libgfortran.5.dylib' (no such file, not in dyld cache)


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/pierremariotti/Documents/PhD/FEniCSx/new_try2/root/ABC_FEniCSx_classical/test_oldABCnewVn.py", line 1, in <module>
    import numpy as np
  File "/opt/anaconda3/envs/env3-10-complex/lib/python3.10/site-packages/numpy/__init__.py", line 119, in <module>
    raise ImportError(msg) from e
ImportError: Error importing numpy: you should not try to import numpy from
        its source directory; please exit the numpy source tree, and relaunch
        your python interpreter from there.

The result of conda env export :

(env3-10-complex) pierremariotti@arm64-apple-darwin20 ABC_FEniCSx_classical % conda env export
Error while loading conda entry point: conda-libmamba-solver (module 'libmambapy' has no attribute 'QueryFormat')
name: env3-10-complex
channels:
  - conda-forge
  - defaults
dependencies:
  - bzip2=1.0.8=h99b78c6_7
  - c-ares=1.34.5=h5505292_0
  - c-blosc2=2.17.1=h9cbb436_0
  - ca-certificates=2025.4.26=hbd8a1cb_0
  - cctools_osx-arm64=1010.6=h3b4f5d3_6
  - cffi=1.16.0=py310hdcd7c05_0
  - clang=18.1.8=default_h474c9e2_9
  - clang-18=18.1.8=default_hf90f093_9
  - clang_impl_osx-arm64=18.1.8=h2ae9ea5_24
  - clang_osx-arm64=18.1.8=h07b0088_24
  - clangxx=18.1.8=default_h1ffe849_9
  - compiler-rt=18.1.8=h856b3c1_1
  - compiler-rt_osx-arm64=18.1.8=h832e737_1
  - fenics-basix=0.9.0=py310h32526d0_2
  - fenics-basix-nanobind-abi=0.2.1.18=h9b63b7c_2
  - fenics-dolfinx=0.9.0=py310h6ec959d_12
  - fenics-ffcx=0.9.0=pyh2e48890_0
  - fenics-libbasix=0.9.0=hf7ae0cd_2
  - fenics-libdolfinx=0.9.0=py310he0777b1_12
  - fenics-ufcx=0.9.0=hb7f7608_0
  - fenics-ufl=2024.2.0=pyhd8ed1ab_1
  - fftw=3.3.10=mpi_mpich_hd148bab_10
  - fmt=11.1.4=h440487c_1
  - hdf5=1.14.3=mpi_mpich_h13a04de_9
  - hypre=2.32.0=mpi_mpich_h189fe77_1
  - icu=75.1=hfee45f7_0
  - kahip=3.18=py310h3e50e70_0
  - krb5=1.21.3=h237132a_0
  - ld64_osx-arm64=951.9=hb6b49e2_6
  - libadios2=2.10.2=mpi_mpich_hfe2f02c_5
  - libaec=1.1.3=hebf3989_0
  - libamd=3.3.3=h5087772_7100102
  - libblas=3.9.0=31_h10e41b3_openblas
  - libboost=1.86.0=hc9fb7c5_3
  - libboost-devel=1.86.0=hf450f58_3
  - libboost-headers=1.86.0=hce30654_3
  - libbtf=2.3.2=h99b4a89_7100102
  - libcamd=3.3.3=h99b4a89_7100102
  - libcblas=3.9.0=31_hb3479ef_openblas
  - libccolamd=3.3.4=h99b4a89_7100102
  - libcholmod=5.3.1=hbba04d7_7100102
  - libclang-cpp18.1=18.1.8=default_hf90f093_9
  - libcolamd=3.3.4=h99b4a89_7100102
  - libcurl=8.13.0=h73640d1_0
  - libcxx=20.1.4=ha82da77_0
  - libcxx-devel=18.1.8=h6dc3340_8
  - libedit=3.1.20250104=pl5321hafb1f1b_0
  - libev=4.33=h93a5062_2
  - libexpat=2.7.0=h286801f_0
  - libfabric=2.1.0=hce30654_1
  - libfabric1=2.1.0=h5505292_1
  - libffi=3.4.6=h1da3d7d_1
  - libgfortran=5.0.0=14_2_0_h6c33f7e_103
  - libgfortran5=14.2.0=h6c33f7e_103
  - libglib=2.84.1=hbec27ea_1
  - libhwloc=2.11.2=default_hbce5d74_1001
  - libiconv=1.18=hfe07756_1
  - libintl=0.24.1=h493aca8_0
  - libklu=2.3.5=h4370aa4_7100102
  - liblapack=3.9.0=31_hc9a63f6_openblas
  - libllvm18=18.1.8=hc4b4ae8_3
  - liblzma=5.8.1=h39f12f2_0
  - libnghttp2=1.64.0=h6d7220d_0
  - libopenblas=0.3.29=openmp_hf332438_0
  - libpng=1.6.47=h3783ad8_0
  - libptscotch=7.0.6=hcfc2647_1
  - libscotch=7.0.6=hd10c9a7_1
  - libsodium=1.0.20=h99b78c6_0
  - libspqr=4.3.4=h775d698_7100102
  - libsqlite=3.49.1=h3f77e49_2
  - libssh2=1.11.1=h1590b86_0
  - libsuitesparseconfig=7.10.1=h4a8fc20_7100102
  - libumfpack=6.3.5=h7c2c975_7100102
  - libxml2=2.13.7=h52572c6_1
  - libzlib=1.3.1=h8359307_2
  - llvm-openmp=20.1.4=hdb05f8b_0
  - llvm-tools=18.1.8=hc4b4ae8_3
  - llvm-tools-18=18.1.8=hc4b4ae8_3
  - lz4-c=1.10.0=h286801f_1
  - metis=5.1.0=h15f6cfe_1007
  - mpi=1.0.1=mpich
  - mpi4py=4.0.3=py310h8a9557c_0
  - mpich=4.3.0=h9d9a6ae_100
  - mumps-include=5.7.3=h71ed9e6_10
  - mumps-mpi=5.7.3=h4795f8b_10
  - ncurses=6.5=h5e97a16_3
  - numpy=2.2.5=py310h4d83441_0
  - openssl=3.5.0=h81ee809_1
  - parmetis=4.0.3=ha4b917a_1007
  - pcre2=10.45=ha881caa_0
  - petsc=3.23.0=complex_hefb9e83_3
  - petsc4py=3.23.0=np20py310h0b04470_0
  - pip=25.1.1=pyh8b19718_0
  - pkg-config=0.29.2=hde07d2e_1009
  - pugixml=1.15=hd3d436d_0
  - pycparser=2.22=pyh29332c3_1
  - python=3.10.17=h6cefb37_0_cpython
  - python_abi=3.10=7_cp310
  - readline=8.2=h1d1bf99_2
  - scalapack=2.2.0=h71a4f75_4
  - setuptools=80.1.0=pyhff2d567_0
  - sigtool=0.1.3=h44b9a77_0
  - slepc=3.23.0=complex_h0e2a288_0
  - slepc4py=3.23.0=np20py310h17657d0_0
  - spdlog=1.15.2=h008cadb_0
  - superlu=7.0.1=h81aaeaf_0
  - superlu_dist=9.1.0=h89afcdd_0
  - tapi=1300.6.5=h03f4b80_0
  - tk=8.6.13=h5083fa2_1
  - tzdata=2025b=h78e105d_0
  - wheel=0.45.1=pyhd8ed1ab_1
  - yaml=0.2.5=h3422bc3_2
  - zeromq=4.3.5=hc1bb282_7
  - zfp=1.0.1=h1c5d8ea_2
  - zlib-ng=2.2.4=h13dfb9a_0
  - zstd=1.5.7=h6491c7d_2
prefix: /opt/anaconda3/envs/env3-10-complex
(env3-10-complex) pierremariotti@arm64-apple-darwin20 ABC_FEniCSx_classical % rm -rf ~/.cache/fenics        

May thanks for your help… I really need to run again my FEniCSx codes..

Running the signing script has actually caused the problem. You can try re-signing with:

/usr/bin/codesign -s - -f /opt/anaconda3/envs/env3-10-complex/lib/libgfortran.5.dylib

or you might need to clear the conda cache to reinstall a fresh libgfortran.

The line you propose returns an error :

/opt/anaconda3/envs/env3-10-complex/lib/libgfortran.5.dylib: invalid or unsupported format for signature

SO I’ve restarted from the beginning :

  1. coming back to conda activate base
  2. conda clean --all
  3. Re-create the env conda create -n clean310 -c conda-forge python=3.10 fenics-dolfinx 'petsc=*=complex*' mpich
  4. Activate the env conda activate clean310
  5. reinstall the libgfortan and openblas and numpy conda install -c conda-forge --force-reinstall libgfortran openblas numpy

And nothing change I still have the exact same message error :

(clean310) pierremariotti@arm64-apple-darwin20 ABC_FEniCSx_classical % python test_oldABCnewVn.py
Traceback (most recent call last):
  File "/opt/anaconda3/envs/clean310/lib/python3.10/site-packages/numpy/_core/__init__.py", line 23, in <module>
    from . import multiarray
  File "/opt/anaconda3/envs/clean310/lib/python3.10/site-packages/numpy/_core/multiarray.py", line 10, in <module>
    from . import overrides
  File "/opt/anaconda3/envs/clean310/lib/python3.10/site-packages/numpy/_core/overrides.py", line 7, in <module>
    from numpy._core._multiarray_umath import (
ImportError: dlopen(/opt/anaconda3/envs/clean310/lib/python3.10/site-packages/numpy/_core/_multiarray_umath.cpython-310-darwin.so, 0x0002): Library not loaded: @rpath/libgfortran.5.dylib
  Referenced from: <CAA510D4-816A-34E5-9021-485EF5D56159> /opt/anaconda3/envs/clean310/lib/libopenblas.0.dylib
  Reason: tried: '/opt/anaconda3/envs/clean310/lib/libgfortran.5.dylib' (code signature invalid in <C739582F-D95B-303A-9F86-7B43C361ECC7> '/opt/anaconda3/envs/clean310/lib/libgfortran.5.dylib' (errno=85) sliceOffset=0x00000000, codeBlobOffset=0x001BC120, codeBlobSize=0x00003C90), '/opt/anaconda3/envs/clean310/lib/libgfortran.5.dylib' (code signature invalid in <C739582F-D95B-303A-9F86-7B43C361ECC7> '/opt/anaconda3/envs/clean310/lib/libgfortran.5.dylib' (errno=85) sliceOffset=0x00000000, codeBlobOffset=0x001BC120, codeBlobSize=0x00003C90), '/opt/anaconda3/envs/clean310/lib/python3.10/site-packages/numpy/_core/../../../../libgfortran.5.dylib' (code signature invalid in <C739582F-D95B-303A-9F86-7B43C361ECC7> '/opt/anaconda3/envs/clean310/lib/libgfortran.5.dylib' (errno=85) sliceOffset=0x00000000, codeBlobOffset=0x001BC120, codeBlobSize=0x00003C90), '/opt/anaconda3/envs/clean310/lib/python3.10/site-packages/numpy/_core/../../../../libgfortran.5.dylib' (code signature invalid in <C739582F-D95B-303A-9F86-7B43C361ECC7> '/opt/anaconda3/envs/clean310/lib/libgfortran.5.dylib' (errno=85) sliceOffset=0x00000000, codeBlobOffset=0x001BC120, codeBlobSize=0x00003C90), '/opt/anaconda3/envs/clean310/bin/../lib/libgfortran.5.dylib' (code signature invalid in <C739582F-D95B-303A-9F86-7B43C361ECC7> '/opt/anaconda3/envs/clean310/lib/libgfortran.5.dylib' (errno=85) sliceOffset=0x00000000, codeBlobOffset=0x001BC120, codeBlobSize=0x00003C90), '/opt/anaconda3/envs/clean310/bin/../lib/libgfortran.5.dylib' (code signature invalid in <C739582F-D95B-303A-9F86-7B43C361ECC7> '/opt/anaconda3/envs/clean310/lib/libgfortran.5.dylib' (errno=85) sliceOffset=0x00000000, codeBlobOffset=0x001BC120, codeBlobSize=0x00003C90), '/usr/local/lib/libgfortran.5.dylib' (no such file), '/usr/lib/libgfortran.5.dylib' (no such file, not in dyld cache)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/anaconda3/envs/clean310/lib/python3.10/site-packages/numpy/__init__.py", line 114, in <module>
    from numpy.__config__ import show_config
  File "/opt/anaconda3/envs/clean310/lib/python3.10/site-packages/numpy/__config__.py", line 4, in <module>
    from numpy._core._multiarray_umath import (
  File "/opt/anaconda3/envs/clean310/lib/python3.10/site-packages/numpy/_core/__init__.py", line 49, in <module>
    raise ImportError(msg)
ImportError: 

IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!

Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.

We have compiled some common reasons and troubleshooting tips at:

    https://numpy.org/devdocs/user/troubleshooting-importerror.html

Please note and check the following:

  * The Python version is: Python3.10 from "/opt/anaconda3/envs/clean310/bin/python"
  * The NumPy version is: "2.2.5"

and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.

Original error was: dlopen(/opt/anaconda3/envs/clean310/lib/python3.10/site-packages/numpy/_core/_multiarray_umath.cpython-310-darwin.so, 0x0002): Library not loaded: @rpath/libgfortran.5.dylib
  Referenced from: <CAA510D4-816A-34E5-9021-485EF5D56159> /opt/anaconda3/envs/clean310/lib/libopenblas.0.dylib
  Reason: tried: '/opt/anaconda3/envs/clean310/lib/libgfortran.5.dylib' (code signature invalid in <C739582F-D95B-303A-9F86-7B43C361ECC7> '/opt/anaconda3/envs/clean310/lib/libgfortran.5.dylib' (errno=85) sliceOffset=0x00000000, codeBlobOffset=0x001BC120, codeBlobSize=0x00003C90), '/opt/anaconda3/envs/clean310/lib/libgfortran.5.dylib' (code signature invalid in <C739582F-D95B-303A-9F86-7B43C361ECC7> '/opt/anaconda3/envs/clean310/lib/libgfortran.5.dylib' (errno=85) sliceOffset=0x00000000, codeBlobOffset=0x001BC120, codeBlobSize=0x00003C90), '/opt/anaconda3/envs/clean310/lib/python3.10/site-packages/numpy/_core/../../../../libgfortran.5.dylib' (code signature invalid in <C739582F-D95B-303A-9F86-7B43C361ECC7> '/opt/anaconda3/envs/clean310/lib/libgfortran.5.dylib' (errno=85) sliceOffset=0x00000000, codeBlobOffset=0x001BC120, codeBlobSize=0x00003C90), '/opt/anaconda3/envs/clean310/lib/python3.10/site-packages/numpy/_core/../../../../libgfortran.5.dylib' (code signature invalid in <C739582F-D95B-303A-9F86-7B43C361ECC7> '/opt/anaconda3/envs/clean310/lib/libgfortran.5.dylib' (errno=85) sliceOffset=0x00000000, codeBlobOffset=0x001BC120, codeBlobSize=0x00003C90), '/opt/anaconda3/envs/clean310/bin/../lib/libgfortran.5.dylib' (code signature invalid in <C739582F-D95B-303A-9F86-7B43C361ECC7> '/opt/anaconda3/envs/clean310/lib/libgfortran.5.dylib' (errno=85) sliceOffset=0x00000000, codeBlobOffset=0x001BC120, codeBlobSize=0x00003C90), '/opt/anaconda3/envs/clean310/bin/../lib/libgfortran.5.dylib' (code signature invalid in <C739582F-D95B-303A-9F86-7B43C361ECC7> '/opt/anaconda3/envs/clean310/lib/libgfortran.5.dylib' (errno=85) sliceOffset=0x00000000, codeBlobOffset=0x001BC120, codeBlobSize=0x00003C90), '/usr/local/lib/libgfortran.5.dylib' (no such file), '/usr/lib/libgfortran.5.dylib' (no such file, not in dyld cache)


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/pierremariotti/Documents/PhD/FEniCSx/new_try2/root/ABC_FEniCSx_classical/test_oldABCnewVn.py", line 2, in <module>
    import numpy as np
  File "/opt/anaconda3/envs/clean310/lib/python3.10/site-packages/numpy/__init__.py", line 119, in <module>
    raise ImportError(msg) from e
ImportError: Error importing numpy: you should not try to import numpy from
        its source directory; please exit the numpy source tree, and relaunch
        your python interpreter from there.

if you’re still getting a bad signature, that means the patched version is still getting installed. It can be tricky to remove files that are patched in place, but you need to remove the directories /opt/anaconda3/pkgs/libgfortran* before reinstalling.