I'm on a Macbook with M1 (Apple ARM architecture) and I've tried running the following Python code using the layoutparser library, which indirectly uses pycocotools:
import layoutparser as lp
lp.Detectron2LayoutModel()
And I've received the error:
[...]
ImportError:
dlopen([...]/.venv/lib/python3.9/site-packages/pycocotools/_mask.cpython-39-darwin.so, 0x0002):
tried:
'[...]/.venv/lib/python3.9/site-packages/pycocotools/_mask.cpython-39-darwin.so'
(mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')),
'/usr/local/lib/_mask.cpython-39-darwin.so' (no such file),
'/usr/lib/_mask.cpython-39-darwin.so' (no such file)
The crucial info for me seems to be [...] is an incompatible architecture (have 'x86_64', need 'arm64e') [...]
. Indeed, I am using the Apple ARM architecture, and sometimes it is not supported by some software. This is usually solved by using Rosetta, which simulates an Intel-x64 architecture. So I start a terminal with Rosetta (arch -x86_64 zsh
), create a new virtual environment, make a fresh install of the dependencies, and try to run the code again ...
... and I receive the same error that I had also had without Rosetta:
[...] is an incompatible architecture (have 'x86_64', need 'arm64e') [...]
I've double-checked that Rosetta is really activated:
> uname -m
x86_64
Rosetta seems to be working. And yet, according to the error message, it seems not to be working.
Any ideas what could be the problem with Rosetta, or the library, or whatever, and how I could try fixing it?