andrewssobral / bgslibrary

A C++ Background Subtraction Library with wrappers for Python, MATLAB, Java and GUI on QT

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Importing python library on M1 chip MacOS

xavibou opened this issue · comments

Hi @andrewssobral,

I am having issues importing the python library with M1 chip MacOS. It seems to be related to the architecture of my machine. I describe my environment and how to reproduce the bug does below:

I have compiled bgslibrary with support for Python on MacOS as stated in https://github.com/andrewssobral/bgslibrary/wiki/Wrapper:-Python. The code compiled well using a Conda environment with the following installations:
-OpenCV 3.4.7
-Python 3.8.6 (Anaconda)

Compilation was done with:
cmake -D BGS_PYTHON_SUPPORT=ON ..

Then, I added the generated lib (pybgs.cpython-39-darwin.so) to my Python path:
export PYTHONPATH="${PYTHONPATH}:/Users/xavibou/Documents/repos/change_detection/methods/bgslibrary/build"

When try to run the demo with the command python demo.py, I get the following error:

Traceback (most recent call last):
File "/Users/xavibou/Documents/repos/change_detection/methods/bgslibrary/demo.py", line 3, in
import pybgs as bgs
ImportError: dlopen(/Users/xavibou/Documents/repos/change_detection/methods/bgslibrary/build/pybgs.cpython-39-darwin.so, 0x0002): tried: '/Users/xavibou/Documents/repos/change_detection/methods/bgslibrary/build/pybgs.cpython-39-darwin.so' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/usr/local/lib/pybgs.cpython-39-darwin.so' (no such file), '/usr/lib/pybgs.cpython-39-darwin.so' (no such file)

Thank you,
Xavi

Hello @xavibou
Thanks for opening this issue.
Yes it's related to the architecture.
However, I need to investigate it more deeply, it's not clear to me how to fix it.