Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with CBC library in Python-MIP on macOS ARM64 (Apple Silicon) #406

Open
juanbellonrz opened this issue Jan 21, 2025 · 0 comments
Open

Comments

@juanbellonrz
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant