Compatibility with Apple Silicon M1
I get the error every time after import dlib:
import dlib
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/dlib/__init__.py", line 19, in <module>
from _dlib_pybind11 import *
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/_dlib_pybind11.cpython-39-darwin.so, 2): no suitable image found. Did find:
/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/_dlib_pybind11.cpython-39-darwin.so: mach-o, but wrong architecture
/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/_dlib_pybind11.cpython-39-darwin.so: mach-o, but wrong architecture
I try rebuild dlib with some settings arch.
I am using Apple Silicon M1:
- face_recognition version: latest
- Python version: 3.9.1 [Clang 6.0 (clang-600.0.57)] on darwin / 3.8.2 [Clang 12.0.0 (clang-1200.0.32.27)] on darwin
- Operating System: macOS Big Sur 11.1
file "$( "$(which python3)" -c "import sys;print(sys.executable)" )"
/Library/Developer/CommandLineTools/usr/bin/python3: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit executable x86_64] [arm64:Mach-O 64-bit executable arm64]
/Library/Developer/CommandLineTools/usr/bin/python3 (for architecture x86_64): Mach-O 64-bit executable x86_64
/Library/Developer/CommandLineTools/usr/bin/python3 (for architecture arm64): Mach-O 64-bit executable arm64
Warning: this issue has been inactive for 35 days and will be automatically closed on 2021-02-02 if there is no further activity.
If you are waiting for a response but haven't received one it's possible your question is somehow inappropriate. E.g. it is off topic, you didn't follow the issue submission instructions, or your question is easily answerable by reading the FAQ, dlib's official compilation instructions, dlib's API documentation, or a Google search.
Warning: this issue has been inactive for 43 days and will be automatically closed on 2021-02-02 if there is no further activity.
If you are waiting for a response but haven't received one it's possible your question is somehow inappropriate. E.g. it is off topic, you didn't follow the issue submission instructions, or your question is easily answerable by reading the FAQ, dlib's official compilation instructions, dlib's API documentation, or a Google search.
Having the same issue with Apple Silicon
Tried on python 3.8.2 and 3.9.1 with the same result. Any idea how to proceed?
For me this config worked
I have used the default python3 shipped with my Mac m1 and used terminal with rosetta
Then I have created a new python3 environment using
python3 -m venv env_name
We need homebrew to install the dependencies
We need cmake and dlib which can be installed as follows
brew install cmake
brew install dlib
After successful installation of cmake and dlib, activate your environment using
source env_name/bin/activate
Then install dlib in python3
python3 -m pip install dlib
after successful installation launch python3 and import dlib
This worked for me
Warning: this issue has been inactive for 35 days and will be automatically closed on 2021-05-01 if there is no further activity.
If you are waiting for a response but haven't received one it's possible your question is somehow inappropriate. E.g. it is off topic, you didn't follow the issue submission instructions, or your question is easily answerable by reading the FAQ, dlib's official compilation instructions, dlib's API documentation, or a Google search.
Warning: this issue has been inactive for 42 days and will be automatically closed on 2021-05-01 if there is no further activity.
If you are waiting for a response but haven't received one it's possible your question is somehow inappropriate. E.g. it is off topic, you didn't follow the issue submission instructions, or your question is easily answerable by reading the FAQ, dlib's official compilation instructions, dlib's API documentation, or a Google search.
Notice: this issue has been closed because it has been inactive for 45 days. You may reopen this issue if it has been closed in error.
still have same problem
On m1 Mac install miniforge3 as mentioned here https://developer.apple.com/metal/tensorflow-plugin/
brew install cmake
brew install dlib
python -m venv .venv
source .venv/bin/activate
pip install dlib
face_recognition
Worked for me!
This issue is already a year old, but doesn't seem to be solved. The above solution only works for Python versions 3.9 and higher, but what if you must use a lower python version?
Does anyone still have this issue, like me? Any solutions in sight?
@agilebean I met this problem today and solved it finally. You may check your cmake: file which cmake, make sure it is arm64 executable.
solved it by linking the libpng library for me:
brew install libpng
export C_INCLUDE_PATH=/opt/homebrew/Cellar/libpng/1.6.37/include
export LIBRARY_PATH=/opt/homebrew/Cellar/libpng/1.6.37/lib
pip3 install dlib --force-reinstall
(replace 1.6.37 by your installed version of libpng)
I am still facing that problem with all the above suggested solutions.
import dlib
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/dlib/__init__.py", line 19, in <module>
from _dlib_pybind11 import *
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/_dlib_pybind11.cpython-310-darwin.so, 0x0002): symbol not found in flat namespace (_png_do_expand_palette_rgb8_neon
Do you have any other recommendations?
Has there been any updates on this issue, I have tried all suggested solutions and still receive the same error.
dlopen(/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/_dlib_pybind11.cpython-310-darwin.so, 0x0002): symbol not found in flat namespace (_png_do_expand_palette_rgb8_neon)
I am having the same issue except with a different missing name space.
Currently using an M1 mac and a conda virtual environment. I have already installed cmake, used the brew install libpng and pip install --upgrade setuptools
I have only been able to install dlib using
pip install dlib==19.17.0
as just pip install dlib was giving me the cmake wheel error
ImportError: dlopen(//opt/anaconda3/envs/DeepFake/lib/python3.10/site-packages/dlib.cpython-310-darwin.so, 0x0002): symbol not found in flat namespace '_XAllocColor'
On m1 Mac install miniforge3 as mentioned here https://developer.apple.com/metal/tensorflow-plugin/
brew install cmake brew install dlib python -m venv .venv source .venv/bin/activate pip install dlib face_recognitionWorked for me!
I had the same problem on M2 - MacOS Sonoma 14.3. After I brew install cmake and dlib to my system, I have no problem in any other virtual environment.
Firstly, on my terminal:
brew install cmake
brew install dlib
Then, start a clean environemt
python -m venv .venv
source .venv/bin/activate # I did not see any reason for pip install dlib
pip install opencv-python
pip install face_recognition
pip install git+https://github.com/ageitgey/face_recognition_models. # asked when I tried to test import face_recognition
Test imports
python
import cv2
import face_recognition
Python 3.12.4
Package Version
----------------------- ---------
click 8.1.7
dlib 19.24.5
face-recognition 1.3.0
face_recognition_models 0.3.0
numpy 2.0.1
opencv-python 4.10.0.84
pillow 10.4.0
pip 24.0
@maritaganta Having the same issue with M2, Any idea how to proceed?