Python optimization libraries

Updated Nov 2026

Python optimization libraries find the inputs that minimize or maximize an objective, subject to constraints. A dedicated solver handles one class of problem, such as linear, quadratic, or conic programs, rather than an arbitrary function. These libraries let engineers and data scientists tune models, schedules, and designs toward the best result.

Popularity

SciPy has the most monthly downloads in this comparison, at 392.1M, a count that covers all its scientific computing.

LibraryMonthly downloadsStarsLast releaseLicense
SciPy
392.1M
15.2KAug 2026BSD-3-Clause
Optuna
14.5M
15.1KNov 2026MIT
OR-Tools
8.4M
14.4KJan 2026Apache-2.0
HiGHS
7.2M
1.9KNov 2026MIT
OSQP
6.6M
130Jun 2026Apache-2.0
PuLP
6.4M
2.5KOct 2026MIT
Clarabel
5.4M
629Jun 2025Apache-2.0
SCS
5.3M
48Nov 2026MIT
Downloads: PyPI, last thirty days. Stars and releases: GitHub. Amber: no release in over a year.

Libraries and code examples

Provides numerical optimization routines for objectives, constraints, and mixed-integer linear programs.

Downloads / mo
392.1M
Stars
15.2K
Last release
1.18.1
License
BSD-3-Clause

Strengths

  • Optimizes Python objective functions. Pass an objective function directly to minimize.
  • Includes mixed-integer linear optimization. Use milp for linear models with integer decisions.

Limitations

  • Minimize targets local minima. Choose a global optimizer when a local minimum is insufficient.

Quickstart

From optimize.html
$ pip install scipy==1.18.1
from scipy.optimize import minimize
result = minimize(lambda x: (x[0] - 2.0) ** 2, x0=[0.0])
print(result.x)

SciPy examples

From open-source projects on GitHub

Optimizes hyperparameters.

Downloads / mo
14.5M
Stars
15.1K
Last release
5.1.0
License
MIT

Quickstart

From README.md
$ pip install optuna==5.1.0
import optuna
def objective(trial):
    x = trial.suggest_float("x", -10.0, 10.0)
    return (x - 2.0) ** 2
study = optuna.create_study()
study.optimize(objective, n_trials=10)
print(study.best_params)

Optuna examples

From open-source projects on GitHub

Provides the Google OR-Tools Python libraries and modules.

Downloads / mo
8.4M
Stars
14.4K
Last release
9.15.6755
License
Apache-2.0

Quickstart

From README.md
$ pip install ortools==9.15.6755
from ortools.linear_solver import pywraplp
solver = pywraplp.Solver.CreateSolver("GLOP")
x = solver.NumVar(0.0, 3.0, "x")
solver.Add(x >= 1.0)
solver.Minimize(x)
status = solver.Solve()
if status == pywraplp.Solver.OPTIMAL:
    print(x.solution_value())

OR-Tools examples

From open-source projects on GitHub

Wraps HiGHS in a thin set of pybind11 bindings.

Downloads / mo
7.2M
Stars
1.9K
Last release
1.16.0
License
MIT

Quickstart

From README.md
$ pip install highspy==1.16.0
import highspy
solver = highspy.Highs()
x = solver.addVariable(lb=0.0, ub=3.0)
solver.addConstr(x >= 1.0)
solver.minimize(x)
print(solver.val(x))

HiGHS examples

From open-source projects on GitHub

Solves quadratic programs with operator splitting.

Downloads / mo
6.6M
Stars
130
Last release
1.1.3
License
Apache-2.0

Quickstart

From python.rst
$ pip install osqp==1.1.3
import numpy as np
from scipy import sparse
import osqp
solver = osqp.OSQP()
solver.setup(P=sparse.csc_matrix([[1.0]]), q=np.array([0.0]), A=sparse.csc_matrix([[1.0]]), l=np.array([1.0]), u=np.array([np.inf]), verbose=False)
print(solver.solve(raise_error=False).x)

OSQP examples

From open-source projects on GitHub

Builds linear and mixed-integer models and sends them to selected solvers.

Downloads / mo
6.4M
Stars
2.5K
Last release
4.2.0
License
MIT

Strengths

  • Defines integer decisions. Set integer variable types when building a linear model.
  • Exports solver-ready models. Write LP or MPS files for external solver workflows.

Limitations

  • Solver binaries are installed separately. Install a solver extra or supply an accessible solver.
  • Native expressions stay linear. Use Pyomo for nonlinear objectives or constraints.

Quickstart

From README.rst
$ pip install "pulp[cbc]==4.2.0"
from pulp import LpProblem, LpMinimize, COIN_CMD, value
problem = LpProblem("demo", LpMinimize)
x = problem.add_variable("x", 0.0, 3.0)
problem += x
problem += x >= 1.0
stats = problem.solve(COIN_CMD(msg=False))
print(stats.status_str, value(x))

PuLP examples

From open-source projects on GitHub
def __contains__(self, x: object) -> bool:
        try:
            import pulp

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

Solves conic problems with an interior-point method.

Downloads / mo
5.4M
Stars
629
Last release
0.11.1
License
Apache-2.0

Quickstart

From getting_started_py.md
$ pip install clarabel==0.11.1
import numpy as np
from scipy import sparse
import clarabel
settings = clarabel.DefaultSettings()
settings.verbose = False
solver = clarabel.DefaultSolver(sparse.csc_matrix((1, 1)), np.array([1.0]), sparse.csc_matrix([[-1.0]]), np.array([-1.0]), [clarabel.NonnegativeConeT(1)], settings)
print(solver.solve().x)

Clarabel examples

From open-source projects on GitHub

Solves conic problems with a splitting method.

Downloads / mo
5.3M
Stars
48
Last release
3.3.2
License
MIT

Quickstart

From python.rst
$ pip install scs==3.3.2
import numpy as np
from scipy import sparse
import scs
data = {"A": sparse.csc_matrix([[-1.0]]), "b": np.array([-1.0]), "c": np.array([1.0])}
solver = scs.SCS(data, {"l": 1}, verbose=False)
print(solver.solve()["x"])

SCS examples

From open-source projects on GitHub

FAQ

SciPy suits general objective functions, least squares, and linear programs. OR-Tools suits scheduling, routing, and other discrete models. Optuna suits tuning hyperparameters and other black-box objectives.

Optuna optimizes black-box objectives through trials that sample float, integer, and categorical parameters. It prunes unpromising trials and supports custom samplers.

The scipy.optimize module in SciPy minimizes objective functions with local and global methods. It also handles nonlinear constraints, least squares, linear programming, and mixed-integer linear programming.

OSQP solves convex quadratic programs from sparse matrix inputs. It can update the problem data and solve again without repeating the setup.

For coding agents

Found your optimization library? Help your agent use it.

Connect Exa so your coding agent can find the library’s documentation, check its API, and look up implementations while you build.

Run in your terminal

claude plugin install exa@claude-plugins-official