Skip to main content

Coin-or CBC native interface for Python

Project description

Linux Build Status

Windows Build status


Native Python interface for Coin-or Branch and Cut Solver (Cbc).


This project provide the build mechanism to automatically generate the wrapper code between Cbc C++ code and Python using SWIG.

This project was develop as part of the CBC Coin-or Sprint Aug 2019.

Binaries for the following platform are pre-compiled and available on pypi.

  • linux x86_64 / python 2.7
  • linux x86_64 / python 3.5
  • linux x86_64 / python 3.6
  • linux x86_64 / python 3.7
  • win x86 / python 2.7
  • win x86 / python 3.5
  • win x86 / python 3.6
  • win x86 / python 3.7
  • win x86_64 / python 3.5
  • win x86_64 / python 3.6
  • win x86_64 / python 3.7

Linux x86 is not supported.


Pre-compiled python packages are deployed to cbcpy Pypi repositories. To install cbcpy you should make use of pip command line:

pip install cbcpy

The packages include pre-compiled version of Cbc.

For Windows: You must install Visual C++ Redistributable for VS2015


Here a minimalistic python script making use of cbcpy. You may download p0033.mps from here.

import cbcpy as cbc
solver1 = cbc.OsiClpSolverInterface()
model = cbc.CbcModel(solver1)
numberColumns = model.solver().getNumCols()
p_solution = model.solver().getColSolution()
solution = cbc.doubleArray_frompointer(p_solution)

for i in range(numberColumns):
  value = solution[i]
  print("%s has value %s" % (i, value))


Original documentation from Cbc project is available in python using the help() function.

# python
Python 2.7.16 (default, Jul 13 2019, 16:01:51) 
[GCC 8.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import cbcpy
>>> help(cbcpy)
Help on module cbcpy:


The specified module could not be found.

>>> import cbcpy
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python37-32\lib\site-packages\", line 15, in <module>
    import _cbcpy
ImportError: DLL load failed: The specified module could not be found.

This error might occur on Windows platform when the file msvcp140.dll cannot be found. You must install Visual C++ Redistributable for VS2015. For 32-bit download "vc_redist.x86.exe" file and for 64-bit download "vc_redist.x64.exe" file.


To get community help for cbcpy, you may send email to the Cbc mailing list.

You may also get paid support by contacting Patrik Dufresne Service Logiciel.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Built Distributions

cbcpy-2.10.3a2-cp37-cp37m-win_amd64.whl (2.1 MB view hashes)

Uploaded cp37

cbcpy-2.10.3a2-cp37-cp37m-win32.whl (1.7 MB view hashes)

Uploaded cp37

cbcpy-2.10.3a2-cp36-cp36m-win_amd64.whl (2.1 MB view hashes)

Uploaded cp36

cbcpy-2.10.3a2-cp36-cp36m-win32.whl (1.7 MB view hashes)

Uploaded cp36

cbcpy-2.10.3a2-cp35-cp35m-win_amd64.whl (2.1 MB view hashes)

Uploaded cp35

cbcpy-2.10.3a2-cp35-cp35m-win32.whl (1.7 MB view hashes)

Uploaded cp35

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page