Issue with CBC library in Python-MIP on macOS ARM64 (Apple Silicon)
- Dominant language
- Linear Programming
- Stars
- 600
- Forks
- 108
- PR merge metrics
- No merged PRs in 30d
Description
Hi, I’m trying to run a Python script that uses the python-mip library with the CBC solver on a MacBook with an ARM64 (Apple Silicon) chip.
- I’ve installed CBC correctly using Homebrew (brew install cbc), and I can verify its availability by running cbc --version in the terminal.
- However, when I run my script in Spyder, I get the following error:
An error occurred while loading the CBC library: cannot load library 'cbc-c-darwin-x86-64.dylib'...
mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')
....
NameError: name 'cbclib' is not defined
- I checked that my CBC installation is for ARM64 using:
file /opt/homebrew/lib/libcbc.dylib
# Output: Mach-O 64-bit dynamically linked shared library arm64
- I have also added the following environment variables in my script before importing mip:
import os
import ctypes
os.environ["DYLD_LIBRARY_PATH"] = "/opt/homebrew/lib:/opt/anaconda3/lib"
os.environ["PATH"] = "/opt/homebrew/bin:" + os.environ.get("PATH", "")
ctypes.CDLL("/opt/homebrew/lib/libcbc.dylib")
from mip import Model, CBC
model = Model(solver_name=CBC)
Despite these efforts, the issue persists. The script runs fine from the terminal, but in Spyder, I still get the architecture mismatch error.
I would appreciate any suggestions on how to force python-mip to use the correct version of CBC installed via Homebrew or how to resolve this compatibility issue in Spyder.
Thanks in advance.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.