# Python linear programming libraries

Python linear programming libraries model optimization problems as a linear objective with linear constraints and solve them for the best values. A modeling library builds the problem and hands it to a separate solver engine. These libraries let developers plan schedules, routes, and production mixes within fixed limits.

## Popularity

| Library | Monthly downloads | Stars | Last release | License |
| --- | --- | --- | --- | --- |
| [SciPy](#scipy) | 392.1M | 15.2K | Aug 2026 | BSD-3-Clause |
| [OR-Tools](#or-tools) | 8.4M | 14.4K | Jan 2026 | Apache-2.0 |
| [HiGHS](#highspy) | 7.2M | 1.9K | Nov 2026 | MIT |
| [OSQP](#osqp) | 6.6M | 130 | Jun 2026 | Apache-2.0 |
| [PuLP](#pulp) | 6.4M | 2.5K | Oct 2026 | MIT |
| [Clarabel](#clarabel) | 5.4M | 629 | Jun 2025 | Apache-2.0 |
| [SCS](#scs) | 5.3M | 48 | Nov 2026 | MIT |
| [CVXPY](#cvxpy) | 5.3M | 6.4K | Sep 2026 | Apache-2.0 |

Downloads: PyPI, last thirty days. Stars and releases: GitHub. Amber: no release in over a year.

[SciPy](#scipy) has the most monthly downloads in this comparison, at 392.1M, a count that covers all its scientific computing.

## Capabilities

| Library | Integer variables | Native cone constraints | Named algebraic models |
| --- | --- | --- | --- |
| [SciPy](#scipy) | Yes | No | No |
| [OR-Tools](#or-tools) | Yes | No | Yes |
| [HiGHS](#highspy) | Yes | No | Yes |
| [OSQP](#osqp) | No | No | No |
| [PuLP](#pulp) | Yes | No | Yes |
| [Clarabel](#clarabel) | No | Yes | No |
| [SCS](#scs) | No | Yes | No |
| [CVXPY](#cvxpy) | Yes | Yes | Yes |

## Libraries

### SciPy

[GitHub](https://github.com/scipy/scipy) · [PyPI](https://pypi.org/project/scipy) · [Docs](https://pypi.org/project/scipy/)

Provides fundamental algorithms for scientific computing.

- Downloads / mo: 392.1M
- Stars: 15.2K
- Last release: 1.18.1
- License: BSD-3-Clause
- Capabilities: [From the SciPy docs](https://pypi.org/project/scipy/)

```sh
pip install scipy
```

**cvxpy/cvxpy** (6.4K stars)

[cvxpy/cvxpy](https://github.com/cvxpy/cvxpy) 

```python
def solve_via_data(self, data, warm_start: bool, verbose: bool, solver_opts, solver_cache=None):
    from scipy import optimize as opt

    # Set default method which can be overridden by user inputs.
    meth = "highs"

    # Check if the problem is a MIP.
    problem_is_a_mip = data[s.BOOL_IDX] or data[s.INT_IDX]

    # Build variable bounds from BOUNDED_VARIABLES data
    n = data[s.C].shape[0]
    lb = data.get(s.LOWER_BOUNDS)
    ub = data.get(s.UPPER_BOUNDS)

    # Track variable integrality options. An entry of zero implies that
    # the variable is continuous. An entry of one implies that the
    # variable is either binary or an integer with bounds.
    if problem_is_a_mip:
        integrality = [0] * n

        for index in data[s.BOOL_IDX] + data[s.INT_IDX]:
            integrality[index] = 1

        bounds = [(
            lb[i] if lb is not None else None,
            ub[i] if ub is not None else None,
        ) for i in range(n)]

        for index in data[s.BOOL_IDX]:
            cur_lb, cur_ub = bounds[index]
            new_lb = max(0, cur_lb) if cur_lb is not None else 0
            new_ub = min(1, cur_ub) if cur_ub is not None else 1
            bounds[index] = (new_lb, new_ub)
    else:
        integrality = None
        if lb is not None or ub is not None:
            bounds = [(
                lb[i] if lb is not None else None,
                ub[i] if ub is not None else None,
            ) for i in range(n)]
        else:
            bounds = (None, None)

    # Extract solver options which are not part of the options dictionary
    if solver_opts:

        # Raise error message if the parameters are not passed in
        # a dictionary called 'scipy_options'.
        if "scipy_options" not in solver_opts:
            raise ValueError("All parameters for the SCIPY solver should "
                             "be encased within a dictionary called "
                             "scipy_options e.g. \n"
                             "prob.solve(solver='SCIPY', verbose=True,"
                             " scipy_options={'method':'highs-ds', 'maxiter':10000})")

        if "method" in solver_opts["scipy_options"]:
            meth = solver_opts["scipy_options"].pop("method")

        # Disable the 'bounds' parameter to avoid problems with
        # canonicalised problems.
        if "bounds" in solver_opts['scipy_options']:
            raise ValueError("Please do not specify bounds through "
                             "scipy_options. Please specify bounds "
                             "through CVXPY.")

        # Check that the 'integrality' parameter isn't specified.
        if "integrality" in solver_opts['scipy_options']:
            raise ValueError("Please do not specify variable integrality through "
                             "scipy_options. Please specify variable types "
                             "through CVXPY.")

        # Check for SciPy method support (i.e., only 'highs' supports MIP models).
        method_supports_mip = meth == 'highs'

        if problem_is_a_mip and not method_supports_mip:
            raise ValueError("Only the 'highs' SciPy method can solve MIP models.")

        # Not supported by HiGHS solvers:
        # callback = solver_opts['scipy_options'].pop("callback", None)
        # x0 = solver_opts['scipy_options'].pop("x0", None)
    else:
        # Instantiate an empty `scipy_options` entry.
        solver_opts['scipy_options'] = {}

    if problem_is_a_mip:
        constraints = []
        G = data[s.G]
        if G is not None:
            ineq = scipy.optimize.LinearConstraint(G, ub=data[s.H])
            # ensure that index arrays are int32
            ineq.A.indptr = ineq.A.indptr.astype(np.int32)
            ineq.A.indices = ineq.A.indices.astype(np.int32)
            constraints.append(ineq)
        A = data[s.A]
        if A is not None:
            eq = scipy.optimize.LinearConstraint(A,data[s.B], data[s.B])
            constraints.append(eq)
        lb = [t[0] if t[0] is not None else -np.inf for t in bounds]
        ub = [t[1] if t[1] is not None else np.inf for t in bounds]
        bounds = scipy.optimize.Bounds(lb, ub)
        solution = opt.milp(data[s.C],
                            constraints=constraints,
                            options=solver_opts['scipy_options'],
                            integrality=integrality,
                            bounds=bounds)
    else:
        solution = opt.linprog(data[s.C], A_ub=data[s.G], b_ub=data[s.H],
                               A_eq=data[s.A], b_eq=data[s.B], method=meth,
                               options=solver_opts['scipy_options'],
                               bounds=bounds)

    # Replace `scipy_options` method to avoid future warnings.
    solver_opts["scipy_options"]["method"] = meth

    if verbose is True:
        print("Solver terminated with message: " + solution.message)

    return solution
```

[cvxpy/reductions/solvers/conic_solvers/scipy_conif.py](https://github.com/cvxpy/cvxpy/blob/0fc467a64a66f5a0f3b7cc721779dca5f1b7ce6f/cvxpy/reductions/solvers/conic_solvers/scipy_conif.py#L103-L220) · [More projects using SciPy →](https://dashboard.exa.ai/playground/search?q=scipy%20GitHub%20projects)

**Quickstart**

```python
from scipy.optimize import linprog

result = linprog([-1.0], bounds=[(0.0, 1.0)], method='highs')
print(result.message)
```

From [scipy.optimize.linprog.html](https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.linprog.html)

### OR-Tools

[GitHub](https://github.com/google/or-tools) · [PyPI](https://pypi.org/project/ortools) · [Docs](https://pypi.org/project/ortools/)

Builds and solves linear models through the MPSolver interface.

- Downloads / mo: 8.4M
- Stars: 14.4K
- Last release: 9.15.6755
- License: Apache-2.0
- Capabilities: [From the OR-Tools docs](https://pypi.org/project/ortools/)

**Strengths**

- **Builds linear models with GLOP.** Use GLOP with numeric variables and linear constraints.
- **Accepts candidate solutions.** Pass an assignment through SetHint before solving.

**Watch out for**

- **Hints can be ignored.** Solvers do not guarantee using a supplied hint.
- **Duals require continuous problems.** Read constraint dual values only for continuous models.

```sh
pip install ortools
```

**guillermo-navas-palencia/optbinning** (539 stars)

[guillermo-navas-palencia/optbinning](https://github.com/guillermo-navas-palencia/optbinning) 

```python
def build_model(self, divergence, n_nonevent, n_event, trend_change):
    # Parameters
    [D, V, pvalue_violation_indices,
     min_diff_violation_indices] = model_data(
        divergence, n_nonevent, n_event, self.max_pvalue,
        self.max_pvalue_policy, self.min_event_rate_diff)

    n = len(n_nonevent)
    n_records = n_nonevent + n_event

    # Initialize solver
    if self.mip_solver == "bop":
        solver = pywraplp.Solver(
            'BinningMIP', pywraplp.Solver.BOP_INTEGER_PROGRAMMING)
    elif self.mip_solver == "cbc":
        solver = pywraplp.Solver(
            'BinningMIP', pywraplp.Solver.CBC_MIXED_INTEGER_PROGRAMMING)

    # Decision variables
    x, y, t, d, u, bin_size_diff = self.decision_variables(solver, n)

    # Objective function
    if self.gamma:
        total_records = int(n_records.sum())
        regularization = self.gamma / total_records
        pmax = solver.IntVar(0, total_records, "pmax")
        pmin = solver.IntVar(0, total_records, "pmin")

        solver.Maximize(solver.Sum([(V[i][i] * x[i, i]) +
                        solver.Sum([(V[i][j] - V[i][j+1]) * x[i, j]
                                    for j in range(i)])
                                    for i in range(n)]) -
                        regularization * (pmax - pmin))
    else:
        solver.Maximize(solver.Sum([(V[i][i] * x[i, i]) +
                        solver.Sum([(V[i][j] - V[i][j+1]) * x[i, j]
                                    for j in range(i)])
                                    for i in range(n)]))

    # Constraint: unique assignment
    self.add_constraint_unique_assignment(solver, n, x)

    # Constraint: continuity
    self.add_constraint_continuity(solver, n, x)

    # Constraint: min / max bins
    self.add_constraint_min_max_bins(solver, n, x, d)

    # Constraint: min / max bin size
    self.add_constraint_min_max_bin_size(solver, n, x, u, n_records,
                                         bin_size_diff)

    # Constraint: min / max n_nonevent per bin
    if (self.min_bin_n_nonevent is not None or
            self.max_bin_n_nonevent is not None):
        for i in range(n):
            bin_ne_size = solver.Sum([n_nonevent[j] * x[i, j]
                                      for j in range(i + 1)])

            if self.min_bin_n_nonevent is not None:
                solver.Add(bin_ne_size >= self.min_bin_n_nonevent*x[i, i])

            if self.max_bin_n_nonevent is not None:
                solver.Add(bin_ne_size <= self.max_bin_n_nonevent*x[i, i])

    # Constraint: min / max n_event per bin
    if (self.min_bin_n_event is not None or
            self.max_bin_n_event is not None):
        for i in range(n):
            bin_e_size = solver.Sum([n_event[j] * x[i, j]
                                     for j in range(i + 1)])

            if self.min_bin_n_event is not None:
                solver.Add(bin_e_size >= self.min_bin_n_event * x[i, i])

            if self.max_bin_n_event is not None:
                solver.Add(bin_e_size <= self.max_bin_n_event * x[i, i])

    # Constraints: monotonicity
    if self.monotonic_trend == "ascending":
        self.add_constraint_monotonic_ascending(solver, n, D, x)

    elif self.monotonic_trend == "descending":
        self.add_constraint_monotonic_descending(solver, n, D, x)

    elif self.monotonic_trend == "concave":
        self.add_constraint_monotonic_concave(solver, n, D, x)

    elif self.monotonic_trend == "convex":
        self.add_constraint_monotonic_convex(solver, n, D, x)

    elif self.monotonic_trend in ("peak", "valley"):
        for i in range(n):
            solver.Add(t >= i - n * (1 - y[i]))
            solver.Add(t <= i + n * y[i])

        if self.monotonic_trend == "peak":
            self.add_constraint_monotonic_peak(solver, n, D, x, y)
        else:
            self.add_constraint_monotonic_valley(solver, n, D, x, y)

    elif self.monotonic_trend == "peak_heuristic":
        self.add_constraint_monotonic_peak_heuristic(
            solver, n, D, x, trend_change)

    elif self.monotonic_trend == "valley_heuristic":
        self.add_constraint_monotonic_valley_heuristic(
            solver, n, D, x, trend_change)

    # Constraint: reduction of dominating bins
    if self.gamma:
        for i in range(n):
            bin_size = solver.Sum([n_records[j] * x[i, j]
                                   for j in range(i + 1)])

            solver.Add(pmin <= total_records * (1 - x[i, i]) + bin_size)
            solver.Add(pmax >= bin_size)
        solver.Add(pmin <= pmax)

    # Constraint: max-pvalue
    self.add_constraint_violation(solver, x, pvalue_violation_indices)

    # Constraint: min diff
    self.add_constraint_violation(solver, x, min_diff_violation_indices)

    # Constraint: fixed splits
    self.add_constraint_fixed_splits(solver, n, x)

    self.solver_ = solver
    self._n = n
    self._x = x
```

[optbinning/binning/mip.py](https://github.com/guillermo-navas-palencia/optbinning/blob/b5d8458454728a3a5be2bbde45ba5384663f1346/optbinning/binning/mip.py#L48-L178) · [More projects using OR-Tools →](https://dashboard.exa.ai/playground/search?q=Projects%20using%20ortools%20to%20build%20linear%20or%20mixed-integer%20programs&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```python
from ortools.linear_solver import pywraplp

solver = pywraplp.Solver.CreateSolver('GLOP')
x = solver.NumVar(0, 1, 'x')
solver.Maximize(x)
status = solver.Solve()
print(status)
```

From [linear_programming_example.py](https://developers.google.com/optimization/lp/lp_example)

### HiGHS

[GitHub](https://github.com/ERGO-Code/HiGHS) · [PyPI](https://pypi.org/project/highspy) · [Docs](https://pypi.org/project/highspy/)

Exposes HiGHS model building and solver operations to Python.

- Downloads / mo: 7.2M
- Stars: 1.9K
- Last release: 1.16.0
- License: MIT
- Capabilities: [From the HiGHS docs](https://pypi.org/project/highspy/)

**Strengths**

- **Builds models through Python expressions.** Create variables and constraints with addVariable and addConstr.
- **Exposes constraint dual values.** Read the dual value of a selected constraint after solving.

**Watch out for**

- **HiPO needs an extra package.** Install highspy-extras to use HiPO through Python.

```sh
pip install highspy
```

**cvxpy/cvxpy** (6.4K stars)

[cvxpy/cvxpy](https://github.com/cvxpy/cvxpy) 

```python
def solve_via_data(
    self, data, warm_start: bool, verbose: bool, solver_opts, solver_cache=None
):
    """Returns the result of the call to the solver.

    minimize          cx
        subject to    A x <=  b

    in HiGHS, the opt problem format is,

    minimize          cx
        subject to    lboundA <= A x <= uboundA

    Parameters
    ----------
    data : dict
        Data used by the solver.
    warm_start : bool
        Whether to warm_start HiGHS.
    verbose : bool
        Should the solver print output?
    solver_opts : dict
        Additional arguments for the solver.

    Returns
    -------
    tuple
        (status, optimal value, primal, equality dual, inequality dual)
    """
    import highspy as hp

    # setup problem data
    inf = hp.Highs().inf
    dims = dims_to_solver_dict(data[s.DIMS])

    c = data[s.C]
    # A = sp.vstack([data[s.A], data[s.F]]).tocsc()
    A = data[s.A].tocsc()
    data["Ax"] = A

    leq_start = dims[s.EQ_DIM]
    leq_end = dims[s.EQ_DIM] + dims[s.LEQ_DIM]
    uboundA = data[s.B]
    data["u"] = uboundA
    lboundA = np.concatenate(
        [data[s.B][:leq_start], -inf * np.ones(data[s.B][leq_start:leq_end].shape)]
    )
    data["l"] = lboundA

    # setup highs model
    model = hp.HighsModel()
    lp = model.lp_
    lp.num_col_ = A.shape[1]
    # assert data['n_var'] == A.shape[1]
    lp.num_row_ = A.shape[0]
    # assert data['n_eq'] + data['n_ineq'] == A.shape[0]

    # offset already applied in invert()
    lp.offset_ = 0
    lp.col_cost_ = c
    lp.row_lower_ = lboundA
    lp.row_upper_ = uboundA

    assert A.format == "csc"
    lp.a_matrix_.format_ = hp.MatrixFormat.kColwise
    lp.a_matrix_.start_ = A.indptr
    lp.a_matrix_.index_ = A.indices
    lp.a_matrix_.value_ = A.data

    # Define Variable bounds
    lb = data[s.LOWER_BOUNDS]
    ub = data[s.UPPER_BOUNDS]
    col_lower = np.full(lp.num_col_, -inf, dtype=c.dtype) if lb is None else lb.copy()
    col_upper = np.full(lp.num_col_, inf, dtype=c.dtype) if ub is None else ub.copy()
    # update col_lower and col_upper to account for boolean variables,
    # also set integrality_ for boolean or integers variables
    if data[s.BOOL_IDX] or data[s.INT_IDX]:
        # note that integrality_ can only be assigned a list
        integrality = [hp.HighsVarType.kContinuous] * lp.num_col_
        if data[s.BOOL_IDX]:
            for ind in data[s.BOOL_IDX]:
                integrality[ind] = hp.HighsVarType.kInteger
            bool_mask = np.array(data[s.BOOL_IDX], dtype=int)
            col_lower[bool_mask] = np.maximum(col_lower[bool_mask], 0)
            col_upper[bool_mask] = np.minimum(col_upper[bool_mask], 1)
        for ind in data[s.INT_IDX]:
            integrality[ind] = hp.HighsVarType.kInteger
        lp.integrality_ = integrality
    lp.col_lower_ = col_lower
    lp.col_upper_ = col_upper

    solver = hp.Highs()

    # setup options
    unpack_highs_options_inplace(solver_opts)
    write_model_file = solver_opts.pop("write_model_file", None)
    solver.setOptionValue("log_to_console", verbose)
    for name, value in solver_opts.items():
        # note that calling setOptionValue directly on the solver
        # allows one to pass advanced options that aren't available
        # on the HighOptions class (e.g., presolve_rule_off)
        if solver.setOptionValue(name, value) == hp.HighsStatus.kError:
            raise ValueError(
                f"HIGHS returned status kError for option (name, value): ({name}, {value})"
            )

    if write_model_file:
        # TODO: Names can be collected upstream more systematically
        # (or in the parent class) to be used by all solvers.
        set_column_names_from_variables(lp, data[s.PARAM_PROB].variables)

    solver.passModel(model)

    if write_model_file:
        solver.writeModel(write_model_file)

    if warm_start and solver_cache is not None and self.name() in solver_cache:
        old_solver, old_data, old_result = solver_cache[self.name()]
        old_status = self.STATUS_MAP.get(old_result["model_status"], s.SOLVER_ERROR)
        if old_status in s.SOLUTION_PRESENT:
            solver.setSolution(old_result["solution"])

    # initialize and solve problem
    try:
        solver.run()
        results = {
            "solution": solver.getSolution(),
            "basis": solver.getBasis(),
            "info": solver.getInfo(),
            "model_status": solver.getModelStatus().name,
            "run_time": solver.getRunTime(),
        }
        if results["model_status"] == "kInfeasible":
            results["dual_ray"] = solver.getDualRay()
    except ValueError as e:
        raise SolverError(e)

    if solver_cache is not None:
        solver_cache[self.name()] = (solver, data, results)

    return results
```

[cvxpy/reductions/solvers/conic_solvers/highs_conif.py](https://github.com/cvxpy/cvxpy/blob/0fc467a64a66f5a0f3b7cc721779dca5f1b7ce6f/cvxpy/reductions/solvers/conic_solvers/highs_conif.py#L217-L357) · [More projects using HiGHS →](https://dashboard.exa.ai/playground/search?q=Projects%20using%20highspy%20to%20build%20linear%20or%20mixed-integer%20programs&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```python
import highspy

solver = highspy.Highs()
x = solver.addVariable(lb=0, ub=1, obj=-1)
solver.run()
print(solver.getModelStatus())
```

From [example-py.md](https://ergo-code.github.io/HiGHS/dev/interfaces/python/example-py/)

### OSQP

[GitHub](https://github.com/osqp/osqp-python) · [PyPI](https://pypi.org/project/osqp) · [Docs](https://pypi.org/project/osqp/)

Solves quadratic programs with operator splitting.

- Downloads / mo: 6.6M
- Stars: 130
- Last release: 1.1.3
- License: Apache-2.0
- Capabilities: [From the OSQP docs](https://pypi.org/project/osqp/)

```sh
pip install osqp
```

**cvxpy/cvxpy** (6.4K stars)

[cvxpy/cvxpy](https://github.com/cvxpy/cvxpy) 

```python
def solve_via_data(self, data, warm_start: bool, verbose: bool, solver_opts,
                   solver_cache=None):
    import osqp
    is_pre_v1 = float(osqp.__version__.split('.')[0]) < 1

    P = data[s.P]
    q = data[s.Q]
    A = sp.vstack([data[s.A], data[s.F]]).tocsc()
    data['Ax'] = A
    uA = np.concatenate((data[s.B], data[s.G]))
    data['u'] = uA
    lA = np.concatenate([data[s.B], -np.inf*np.ones(data[s.G].shape)])
    data['l'] = lA

    if P is not None:
        P = sp.csc_matrix((P.data, P.indices, P.indptr), shape=P.shape)
    if A is not None:
        A = sp.csc_matrix((A.data, A.indices, A.indptr), shape=A.shape)

    # Overwrite defaults eps_abs=eps_rel=1e-3, max_iter=4000
    solver_opts['eps_abs'] = solver_opts.get('eps_abs', 1e-5)
    solver_opts['eps_rel'] = solver_opts.get('eps_rel', 1e-5)
    solver_opts['max_iter'] = solver_opts.get('max_iter', 10000)

    # Use cached data
    if warm_start and solver_cache is not None and self.name() in solver_cache:
        solver, old_data, results = solver_cache[self.name()]
        new_args = {}
        for key in ['q', 'l', 'u']:
            if any(data[key] != old_data[key]):
                new_args[key] = data[key]
        factorizing = False
        if P.data.shape != old_data[s.P].data.shape or any(
                P.data != old_data[s.P].data):
            P_triu = sp.csc_array(sp.triu(P, format='csc'))
            new_args['Px'] = P_triu.data
            factorizing = True
        if A.data.shape != old_data['Ax'].data.shape or any(
                A.data != old_data['Ax'].data):
            new_args['Ax'] = A.data
            factorizing = True

        if new_args:
            solver.update(**new_args)
        # Map OSQP statuses back to CVXPY statuses
        status_map = self.STATUS_MAP_PRE_V1 if is_pre_v1 else self.STATUS_MAP
        status = status_map.get(results.info.status_val, s.SOLVER_ERROR)
        if status == s.OPTIMAL:
            solver.warm_start(results.x, results.y)
        # Polish if factorizing.
        polish_param = 'polish' if is_pre_v1 else 'polishing'
        solver_opts[polish_param] = solver_opts.get(polish_param, factorizing)
        solver.update_settings(verbose=verbose, **solver_opts)
    else:
        # Initialize and solve problem
        polish_param = 'polish' if is_pre_v1 else 'polishing'
        solver_opts[polish_param] = solver_opts.get(polish_param, True)
        solver = osqp.OSQP()
        try:
            solver.setup(P, q, A, lA, uA, verbose=verbose, **solver_opts)
        except Exception as e:
            raise SolverError(e)

    results = solver.solve(raise_error=False)

    if solver_cache is not None:
        solver_cache[self.name()] = (solver, data, results)
    return results
```

[cvxpy/reductions/solvers/qp_solvers/osqp_qpif.py](https://github.com/cvxpy/cvxpy/blob/0fc467a64a66f5a0f3b7cc721779dca5f1b7ce6f/cvxpy/reductions/solvers/qp_solvers/osqp_qpif.py#L93-L160) · [More projects using OSQP →](https://dashboard.exa.ai/playground/search?q=osqp%20GitHub%20projects)

**Quickstart**

```python
import numpy as np
from scipy import sparse
import osqp

solver = osqp.OSQP()
solver.setup(P=sparse.csc_matrix((1, 1)), q=np.array([-1.0]),
             A=sparse.csc_matrix([[1.0]]), l=np.array([0.0]), u=np.array([1.0]))
result = solver.solve(raise_error=False)
print(result.info.status)
```

From [python.html](https://osqp.org/docs/interfaces/python.html)

### PuLP

[GitHub](https://github.com/coin-or/pulp) · [PyPI](https://pypi.org/project/pulp) · [Docs](https://pypi.org/project/pulp/)

Models linear and mixed-integer problems for separate solver backends.

- Downloads / mo: 6.4M
- Stars: 2.5K
- Last release: 4.2.0
- License: MIT
- Capabilities: [From the PuLP docs](https://pypi.org/project/pulp/)

**Strengths**

- **Separates modeling from solver choice.** Build a model and select an available solver backend.
- **Exports problems to JSON.** Serialize the model with toJson for later loading.

**Watch out for**

- **CBC needs a separate installation.** Install the CBC extra or supply another solver before solving.
- **Variables now belong to problems.** Create variables through prob.add_variable before adding expressions.

```sh
pip install pulp[cbc]
```

**snakemake/snakemake** (2.9K stars)

[snakemake/snakemake](https://github.com/snakemake/snakemake) 

```python
def __contains__(self, x: object) -> bool:
        try:
            import pulp

            return pulp.getSolver(x).available()
        except Exception:  # noqa: BLE001
            return False
```

[src/snakemake/scheduling/milp.py](https://github.com/snakemake/snakemake/blob/6d007cf012b0d4dfb80d3a7a21c2cd39bec8f7c8/src/snakemake/scheduling/milp.py#L49-L55) · [More projects using PuLP →](https://dashboard.exa.ai/playground/search?q=Projects%20using%20pulp%20to%20build%20linear%20or%20mixed-integer%20programs&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```python
from pulp import LpProblem, LpMinimize

problem = LpProblem('first_model', LpMinimize)
x = problem.add_variable('x', lowBound=0, upBound=1)
problem += -x
stats = problem.solve()
print(stats.status_str)
```

From [README.rst](https://github.com/coin-or/pulp/blob/956e63864a86659d52692b28d54fc7271a566c5b/README.rst)

### Clarabel

[GitHub](https://github.com/oxfordcontrol/Clarabel.rs) · [PyPI](https://pypi.org/project/clarabel) · [Docs](https://pypi.org/project/clarabel/)

Solves conic problems with an interior-point method.

- Downloads / mo: 5.4M
- Stars: 629
- Last release: 0.11.1
- License: Apache-2.0
- Capabilities: [From the Clarabel docs](https://pypi.org/project/clarabel/)

```sh
pip install clarabel
```

**cvxpy/cvxpy** (6.4K stars)

[cvxpy/cvxpy](https://github.com/cvxpy/cvxpy) 

```python
def solve_via_data(self, data, warm_start: bool, verbose: bool, solver_opts, solver_cache=None):
    """Returns the result of the call to the solver.

    Parameters
    ----------
    data : dict
        Data generated via an apply call.
    warm_start : Bool
        Whether to warm_start Clarabel.
    verbose : Bool
        Control the verbosity.
    solver_opts : dict
        Clarabel-specific solver options.

    Returns
    -------
    The result returned by a call to clarabel.solve().
    """
    import clarabel

    A = data[s.A]
    b = data[s.B]
    q = data[s.C]

    if s.P in data:
        P = data[s.P]
    else:
        nvars = q.size
        P = sp.csc_array((nvars, nvars))

    P = sp.triu(P).tocsc()

    cones = dims_to_solver_cones(data[ConicSolver.DIMS])

    def new_solver():

        _settings = self.parse_solver_opts(verbose, solver_opts)
        _solver = clarabel.DefaultSolver(P, q, A, b, cones, _settings)
        return _solver

    def updated_solver():

        if (not warm_start) or (solver_cache is None) or (self.name() not in solver_cache):
            return None

        _solver = solver_cache[self.name()]

        if not hasattr(_solver, "update"):
            return None
        elif not _solver.is_data_update_allowed():
            # disallow when presolve or chordal decomposition is used
            return None
        else:
            # current internal settings, to be updated if needed
            oldsettings = _solver.get_settings()
            newsettings = self.parse_solver_opts(verbose, solver_opts, oldsettings)

            # this overwrites all data in the solver but will not
            # reallocate internal memory.  Could be faster if it
            # were known which terms (or partial terms) have changed.
            try:
                _solver.update(P=P, q=q, A=A, b=b, settings=newsettings)
                return _solver
            except Exception:
                # If sparsity pattern or dimensions changed, update() fails.
                # Return None to trigger a full new_solver() re-initialization.
                return None

    # Try to get cached data
    solver = updated_solver()

    if solver is None:
        solver = new_solver()

    results = solver.solve()

    if solver_cache is not None:
        solver_cache[self.name()] = solver

    return results
```

[cvxpy/reductions/solvers/conic_solvers/clarabel_conif.py](https://github.com/cvxpy/cvxpy/blob/0fc467a64a66f5a0f3b7cc721779dca5f1b7ce6f/cvxpy/reductions/solvers/conic_solvers/clarabel_conif.py#L194-L273) · [More projects using Clarabel →](https://dashboard.exa.ai/playground/search?q=clarabel%20GitHub%20projects)

**Quickstart**

```python
import clarabel
import numpy as np
from scipy import sparse

solver = clarabel.DefaultSolver(
    sparse.csc_matrix((1, 1)), np.array([-1.0]),
    sparse.csc_matrix([[1.0], [-1.0]]), np.array([1.0, 0.0]),
    [clarabel.NonnegativeConeT(2)], clarabel.DefaultSettings())
solution = solver.solve()
print(solution.status)
```

From [README.md](https://clarabel.org/stable/python/getting_started_py/)

### SCS

[GitHub](https://github.com/bodono/scs-python) · [PyPI](https://pypi.org/project/scs) · [Docs](https://pypi.org/project/scs/)

Solves conic problems with a splitting method.

- Downloads / mo: 5.3M
- Stars: 48
- Last release: 3.3.2
- License: MIT
- Capabilities: [From the SCS docs](https://pypi.org/project/scs/)

```sh
pip install scs
```

**cvxpy/cvxpy** (6.4K stars)

[cvxpy/cvxpy](https://github.com/cvxpy/cvxpy) 

```python
def solve_via_data(self, data, warm_start: bool, verbose: bool, solver_opts, solver_cache=None):
    """Returns the result of the call to the solver.

    Parameters
    ----------
    data : dict
        Data generated via an apply call.
    warm_start : Bool
        Whether to warm_start SCS.
    verbose : Bool
        Control the verbosity.
    solver_opts : dict
        SCS-specific solver options.

    Returns
    -------
    The result returned by a call to scs.solve().
    """
    import scs
    args = {"A": data[s.A], "b": data[s.B], "c": data[s.C]}
    if s.P in data:
        args["P"] = data[s.P]
    if warm_start and solver_cache is not None and \
            self.name() in solver_cache:
        args["x"] = solver_cache[self.name()]["x"]
        args["y"] = solver_cache[self.name()]["y"]
        args["s"] = solver_cache[self.name()]["s"]
    cones = dims_to_solver_dict(data[ConicSolver.DIMS])

    def solve(_solver_opts):
        _results = scs.solve(args, cones, verbose=verbose, **_solver_opts)
        _status = self.STATUS_MAP[_results["info"]["status_val"]]
        return _results, _status

    solver_opts = SCS.parse_solver_options(solver_opts)
    results, status = solve(solver_opts)
    if solver_cache is not None and status == s.OPTIMAL:
        solver_cache[self.name()] = results
    return results
```

[cvxpy/reductions/solvers/conic_solvers/scs_conif.py](https://github.com/cvxpy/cvxpy/blob/0fc467a64a66f5a0f3b7cc721779dca5f1b7ce6f/cvxpy/reductions/solvers/conic_solvers/scs_conif.py#L200-L238) · [More projects using SCS →](https://dashboard.exa.ai/playground/search?q=scs%20GitHub%20projects)

**Quickstart**

```python
import numpy as np
from scipy import sparse
import scs

data = {'A': sparse.csc_matrix([[1.0], [-1.0]]),
        'b': np.array([1.0, 0.0]), 'c': np.array([-1.0])}
solver = scs.SCS(data, {'l': 2})
result = solver.solve()
print(result['info']['status'])
```

From [README.md](https://pypi.org/pypi/scs/3.3.2/json#info.description)

### CVXPY

[GitHub](https://github.com/cvxpy/cvxpy) · [PyPI](https://pypi.org/project/cvxpy) · [Docs](https://pypi.org/project/cvxpy/)

Models convex optimization problems in a domain-specific language.

- Downloads / mo: 5.3M
- Stars: 6.4K
- Last release: 1.9.3
- License: Apache-2.0
- Capabilities: [From the CVXPY docs](https://pypi.org/project/cvxpy/)

```sh
pip install cvxpy
```

**PyPortfolio/PyPortfolioOpt** (6.2K stars)

[PyPortfolio/PyPortfolioOpt](https://github.com/PyPortfolio/PyPortfolioOpt) 

```python
def _solve_cvxpy_opt_problem(self):
    """
    Helper method to solve the cvxpy problem and check output,
    once objectives and constraints have been defined

    Raises
    ------
    exceptions.OptimizationError
        if problem is not solvable by cvxpy
    """
    try:
        if self._opt is None:
            self._opt = cp.Problem(cp.Minimize(self._objective), self._constraints)
            self._initial_objective = self._objective.id
            self._initial_constraint_ids = {const.id for const in self._constraints}
        else:
            if not self._objective.id == self._initial_objective:
                raise InstantiationError(
                    "The objective function was changed after the initial optimization. "
                    "Please create a new instance instead."
                )

            constr_ids = {const.id for const in self._constraints}
            if not constr_ids == self._initial_constraint_ids:
                raise InstantiationError(
                    "The constraints were changed after the initial optimization. "
                    "Please create a new instance instead."
                )
        self._opt.solve(
            solver=self._solver, verbose=self._verbose, **self._solver_options
        )

    except (TypeError, cp.DCPError) as e:
        raise OptimizationError from e

    if self._opt.status not in {"optimal", "optimal_inaccurate"}:
        raise OptimizationError("Solver status: {}".format(self._opt.status))
    self.weights = self._w.value.round(16) + 0.0  # +0.0 removes signed zero
    return self._make_output_weights()
```

[pypfopt/base/_base_optimizer.py](https://github.com/PyPortfolio/PyPortfolioOpt/blob/a6638d2e06dae6f444fd022cfd4b3c528902a85b/pypfopt/base/_base_optimizer.py#L307-L345) · [More projects using CVXPY →](https://dashboard.exa.ai/playground/search?q=cvxpy%20GitHub%20projects)

**Quickstart**

```python
import cvxpy as cp

x = cp.Variable()
problem = cp.Problem(cp.Minimize(-x), [x >= 0, x <= 1])
problem.solve()
print(problem.status)
```

From [cvxpy.problems.html](https://www.cvxpy.org/api_reference/cvxpy.problems.html)

## FAQ

### Which Python linear programming library should I use?

[PuLP](#pulp) suits linear and mixed-integer models that can run on several solvers. [OR-Tools](#or-tools) suits models built from named variables through its MPSolver interface. [SciPy](#scipy) suits problems already expressed as arrays.

### What is CVXPY?

[CVXPY](#cvxpy) is a modeling language for convex optimization problems. It checks a problem against disciplined convex programming rules and dispatches it to a compatible installed solver.

### What is PuLP?

[PuLP](#pulp) is a linear programming modeler that writes MPS or LP files and calls solvers such as GLPK, CBC, CPLEX, and Gurobi.

### How do I solve a linear program with SciPy?

[SciPy](#scipy) exposes linear and mixed-integer programming through functions that take the objective and constraints as arrays.

## How this page was built

Data checked Nov 20, 2026.

Reproduce it with the Exa API:

```json
{
  "endpoint": "/search",
  "body": {
    "query": "Best Python linear programming libraries PuLP OR-Tools highspy Python-MIP code examples",
    "numResults": 5
  }
}
```

Docs: https://exa.ai/docs/reference/search
