python-mip: Name 'cbclib' is not defined
Describe the bug
I cannot solve even a very simple program, because the system claims that cbclib is not defined:
Traceback (most recent call last):
File "test_mip.py", line 2, in <module>
m = Model("test", solver_name=CBC)
File "local-packages\Python310\site-packages\mip\model.py", line 87, in __init__
import mip.cbc
File "local-packages\Python310\site-packages\mip\cbc.py", line 603, in <module>
Osi_getNumCols = cbclib.Osi_getNumCols
NameError: name 'cbclib' is not defined
To Reproduce
from mip import Model, CBC
m = Model("test", solver_name=CBC)
Expected behavior No error.
Desktop (please complete the following information):
- Windows 11 22H2
- Python version: 3.10.10
- Python-MIP version (we recommend you to test with the latest version): 1.15.0 (also exists in 1.14.0)
About this issue
- Original URL
- State: open
- Created 4 years ago
- Comments: 21 (3 by maintainers)
Python-MIP’s latest release candidate version (1.16rc0) includes binaries compatible with M1/M2/M3 processors. To install it, you can use pip:
pip3 install mip==1.16rc0The fix
pip3 install mip==1.16rc0was working before on macos-latest github runners, but not anymore since the release of the new image: https://github.com/actions/runner-images/releases/tag/macos-14-arm64%2F20240514.3 Have you an idea what has changed in the runner (see above link) that could explained this?I think my problem is related to this topic
I use M1 pro MacBook. Stack trace:
Key problem is the warning message at the start:
mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')),Look at
lib/python3.11/site-packages/mip/librariesdirectory.There is no macos m1 distribution.
Compile it manually via coinbrew. Swap
cbc-c-darwin-x86-64.dylibwith own compiled file.It works! 🎆
I think you should add precompiled binary for macos m1.
hey, has anyone found a workaround for this issue? 🙏 thaaanks
I think there are two slightly distinct things here:
The cbc module actually goes to some work to check for such an error and set a
has_cbcflag if it fails. The problem is that code further down the file then goes on to unconditionally usecbclib.It seems like this means the error handling here ends up the worst of both worlds and either all of the code in this module other than the initial loading should exist in a
has_cbcblock, or the error from loading cbclib should just be left to propagate.