nlopt
Library for nonlinear optimization, wrapping many algorithms for global and local, constrained or unconstrained, optimization
What it is and what it does
NLopt is a Python wrapper around the NLopt C library, providing access to a collection of non-linear optimization algorithms. It handles both constrained and unconstrained problems, with support for global and local search methods. The package depends only on numpy and is distributed as pre-compiled wheels for modern Python versions on Windows, macOS, and Linux.
Developers use NLopt when they need to solve optimization problems that don't fit standard linear or convex frameworks—fitting parameters to data, tuning hyperparameters, or finding optimal configurations subject to constraints. The library abstracts away algorithm selection and convergence details, allowing you to specify an objective function and let NLopt handle the numerical work.
Use it for:
- Fit model parameters to experimental data by minimizing the difference between predictions and observations
- Tune hyperparameters in machine learning or simulation models subject to bounds and constraints
- Solve engineering design problems where you need to optimize multiple objectives or handle non-convex search spaces
- Find equilibrium points or optimal configurations in physical systems with complex constraint relationships
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
NLopt provides Python bindings to the NLopt library, offering a suite of algorithms for solving non-linear optimization problems with global, local, constrained, and unconstrained variants.
Yes. NLopt is actively maintained, carries no known vulnerabilities, uses a permissive MIT license, and provides precompiled wheels that install cleanly on standard platforms. It is a stable, production-grade library for non-linear optimization with a straightforward API. Install it if you need to solve optimization problems beyond the scope of scipy.optimize or other general-purpose solvers.
Install
nlopt on PyPI
pip
pip install nloptuv
uv add nloptpoetry
poetry add nloptInstalling nlopt
Before you install
Medium install friction due to compiled C++ bindings, but wheels are provided for Python 3.9+ across Windows, macOS, and Linux. Last release was 28 days ago with active repository maintenance.
License in practice
MIT license permits commercial and private use with minimal restrictions; suitable for most projects without licensing concerns.
Quickstart
pip install nlopt
import nlopt
import numpy as np
opt = nlopt.opt(nlopt.LN_COBYLA, 2)
opt.set_min_objective(lambda x, grad: x[0]**2 + x[1]**2)
opt.optimize([1.0, 1.0])
Requires Python 3.9 or later; compiled wheels available for common platforms but may require build tools on unsupported architectures.
Verify before relying
- Specific algorithm count and performance characteristics compared to other optimization libraries
- Whether the package includes derivative-free and gradient-based methods or only a subset
- Support for multi-objective optimization or only single-objective problems
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | 1 — numpy |
| Maintenance | actively maintained — 28 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,083,574/month — #4,392 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: nlopt-2.11.0-cp310-cp310-macosx_11_0_arm64.whl; nlopt-2.11.0-cp310-cp310-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl; nlopt-2.11.0-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl; nlopt-2.11.0-cp310-cp310-win_amd64.whl; nlopt-2.11.0-cp311-cp311-macosx_11_0_arm64.whl; nlopt-2.11.0-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl; nlopt-2.11.0-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl; nlopt-2.11.0-cp311-cp311-win_amd64.whl; nlopt-2.11.0-cp312-cp312-macosx_11_0_arm64.whl; nlopt-2.11.0-cp312-cp312-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl; nlopt-2.11.0-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl; nlopt-2.11.0-cp312-cp312-win_amd64.whl; nlopt-2.11.0-cp313-cp313-macosx_11_0_arm64.whl; nlopt-2.11.0-cp313-cp313-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl; nlopt-2.11.0-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl; nlopt-2.11.0-cp313-cp313-win_amd64.whl; nlopt-2.11.0-cp314-cp314-macosx_11_0_arm64.whl; nlopt-2.11.0-cp314-cp314-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl; nlopt-2.11.0-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl; nlopt-2.11.0-cp314-cp314-win_amd64.whl
Keywords: algorithms, global local constrained unconstrained optimization, optimization, non-linear optimization
Tags
More Scientific/Engineering packages
NumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
pandaspandas provides fast, flexible data structures…
permissive · top 100 on PyPI
scipyscipy provides numerical algorithms for…
permissive · top 100 on PyPI
scikit-learnscikit-learn provides a comprehensive Python…
permissive · top 1,000 on PyPI
dilldill extends Python's pickle module to…
permissive · top 1,000 on PyPI
multiprocessMultiprocess is an enhanced fork of Python's…
permissive · top 1,000 on PyPI
cvxoptcvxopt is a Python library for solving convex…
unclear · top 5,000 on PyPI
lmfitLmfit provides non-linear least-squares…
permissive · top 5,000 on PyPI
swiglpkswiglpk provides direct Python bindings to the…
copyleft · top 15,000 on PyPI
optlangOptlang formulates and solves linear,…
permissive · top 15,000 on PyPI
quadprogSolves strictly convex quadratic programming…
copyleft · top 15,000 on PyPI
docplexModeling library for building and solving…
permissive · top 15,000 on PyPI
pyomoPyomo is a Python framework for formulating and…
permissive · top 5,000 on PyPI
directsearchSolves unconstrained and linearly constrained…
copyleft · top 15,000 on PyPI
osqpOSQP is a Python wrapper for the Operator…
permissive · top 5,000 on PyPI
optbinningOptBinning discretizes numeric variables into…
permissive · top 15,000 on PyPI