[Python] Python dlib not working properly on Apple Silicon chip (M4)

Discussão em 'Python' iniciado por Stack, Fevereiro 28, 2025.

  1. Stack

    Stack Membro Participativo

    I want to use dlib on Python. I installed it without any issue. The problem is that, when I try to import it, I get this error:

    Traceback (most recent call last):
    File "/Users/elgamernovato/Projects/Free Code/Python/Test Proyecto Rene/test.py", line 1, in <module>
    import dlib
    File "/Users/elgamernovato/Projects/Free Code/Python/Test Proyecto Rene/venv/lib/python3.13/site-packages/dlib/__init__.py", line 19, in <module>
    from _dlib_pybind11 import *
    ImportError:
    dlopen(/Users/elgamernovato/Projects/Free Code/Python/Test Proyecto Rene/venv/lib/python3.13/site-packages/_dlib_pybind11.cpython-313-darwin.so, 0x0002):
    tried:
    '/Users/elgamernovato/Projects/Free Code/Python/Test Proyecto Rene/venv/lib/python3.13/site-packages/_dlib_pybind11.cpython-313-darwin.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e' or 'arm64')),
    '/System/Volumes/Preboot/Cryptexes/OS/Users/elgamernovato/Projects/Free Code/Python/Test Proyecto Rene/venv/lib/python3.13/site-packages/_dlib_pybind11.cpython-313-darwin.so' (no such file),
    '/Users/elgamernovato/Projects/Free Code/Python/Test Proyecto Rene/venv/lib/python3.13/site-packages/_dlib_pybind11.cpython-313-darwin.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e' or 'arm64'))


    I installed cmake, boost and openblas using brew. I installed dlib again for arm:

    CMAKE_PREFIX_PATH=$(brew --prefix) arch -arm64 pip install dlib --no-binary dlib


    But still the same error.

    I even ensured python is working for arm64 with

    arch -arm64 python3 -c "import platform; print(platform.machine())"


    On the terminal I ran uname -m to confirm that I am using arm64.

    I expected dlib to import smoothly, but simply importing it causes errors.

    Continue reading...

Compartilhe esta Página