[Python] ImportError when importing NumPy – missing libgfortran.5.dylib on macOS (VS Code,...

Discussão em 'Python' iniciado por Stack, Abril 10, 2025.

  1. Stack

    Stack Membro Participativo

    I’m working on macOS Sequoia 15.4, using VS Code and Jupyter Notebooks with Conda environments.

    Everything worked fine until yesterday. Now, when I try to run any of my existing environments, importing NumPy or other scientific libraries results in the following ImportError related to libgfortran.5.dylib.

    ImportError: dlopen(..._multiarray_umath.cpython-39-darwin.so):
    Library not loaded: @rpath/libgfortran.5.dylib
    Referenced from: /Users/.../miniconda3/envs/PARESIS/lib/libopenblasp-r0.3.21.dylib
    Reason: tried: '/Users/.../libgfortran.5.dylib' (duplicate LC_RPATH '@loader_path'),
    '/usr/local/lib/libgfortran.5.dylib' (no such file),
    '/usr/lib/libgfortran.5.dylib' (no such file, not in dyld cache)


    This ends with:

    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.


    This happens only in older environments. If I create a new Conda environment, everything works fine.

    I tried reinstalling NumPy using

    conda install numpy --force-reinstall


    , and also explicitly installing libgfortran=5 in the affected environment. I also updated Conda, restarted my system, and relaunched VS Code multiple times.

    I expected NumPy to be reinstalled correctly and the missing library issue to be resolved, but the error persists. I was hoping to avoid recreating all my environments from scratch since I have a lot of dependencies already configured.

    Continue reading...

Compartilhe esta Página