cvxpy
A domain-specific language for modeling convex optimization problems in Python.
What it is and what it does
CVXPY is a domain-specific language embedded in Python that lets you write convex optimization problems in mathematical notation rather than solver-specific standard form. You define variables, an objective function, and constraints using CVXPY's API, then call solve() to delegate to one of several open-source solvers (Clarabel, SCS, OSQP, HiGHS). It handles the translation and returns optimal values and dual variables.
The package supports a broad range of problem classes: convex optimization (the primary use case), mixed-integer convex problems, geometric programs, quasiconvex programs, and nonlinear programs. It relies on 8 runtime dependencies—numerical libraries (numpy, scipy, sparsediffpy) and solver backends (osqp, clarabel, scs, highspy, qdldl)—all of which install together. The project is actively maintained, has been in development since 2014, and is widely used in research and industry.
Use it for:
- Solve least-squares problems with variable bounds, as shown in the documentation example.
- Formulate and solve portfolio optimization problems with convex constraints.
- Model resource allocation and scheduling problems as convex or mixed-integer programs.
- Prototype control and signal processing algorithms that rely on convex optimization.
- Solve geometric programming problems for engineering design and optimization.
- Develop machine learning models that incorporate convex loss functions and regularization.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
CVXPY is a Python modeling language for expressing and solving convex optimization problems, mixed-integer convex problems, geometric programs, quasiconvex programs, and nonlinear programs using open-source solvers.
Yes. CVXPY is a mature, actively maintained package (latest release 53 days ago, 6299 GitHub stars) with permissive Apache-2.0 licensing, no known vulnerabilities, and broad solver support. Medium install friction is justified by the complexity of the underlying solvers. Install it if you need to model and solve convex or mixed-integer optimization problems in Python without writing solver-specific code.
Install
cvxpy on PyPI
pip
pip install cvxpyuv
uv add cvxpypoetry
poetry add cvxpyInstalling cvxpy
Before you install
Medium install friction due to 8 runtime dependencies including compiled solvers (osqp, clarabel, scs, highspy, qdldl) and numerical libraries (numpy, scipy, sparsediffpy). Pre-built wheels available for modern Python versions (3.11–3.14) across macOS, Linux, and Windows. Active maintenance with a recent release 53 days ago.
License in practice
Apache-2.0 permissive license allows commercial and private use with minimal restrictions; you may use, modify, and distribute CVXPY and derivative works freely provided you retain license and copyright notices.
Quickstart
pip install cvxpy
import cvxpy as cp
import numpy
x = cp.Variable(20)
objective = cp.Minimize(cp.sum_squares(A @ x - b))
constraints = [0 <= x, x <= 1]
prob = cp.Problem(objective, constraints)
result = prob.solve()
print(x.value)
Requires Python >= 3.11. Solvers (osqp, clarabel, scs, highspy) must be installed as dependencies; additional solvers may require separate installation.
Verify before relying
- Performance characteristics and scalability limits for large-scale problems are not specified in the fact sheet.
- Solver selection strategy and how CVXPY chooses among available solvers (osqp, clarabel, scs, highspy) is not detailed.
- Whether all 8 runtime dependencies are mandatory or if some are optional for specific use cases.
Package facts
| License | Apache-2.0 (permissive) |
| Python support | supports the current Python release (>=3.11) |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | 8 — osqp, clarabel, scs, numpy, scipy, highspy, qdldl, sparsediffpy |
| Maintenance | actively maintained — 53 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 5,130,168/month — #2,162 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: cvxpy-1.9.2-cp311-cp311-macosx_10_9_universal2.whl; cvxpy-1.9.2-cp311-cp311-macosx_10_9_x86_64.whl; cvxpy-1.9.2-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl; cvxpy-1.9.2-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl; cvxpy-1.9.2-cp311-cp311-win_amd64.whl; cvxpy-1.9.2-cp312-cp312-macosx_10_13_universal2.whl; cvxpy-1.9.2-cp312-cp312-macosx_10_13_x86_64.whl; cvxpy-1.9.2-cp312-cp312-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl; cvxpy-1.9.2-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl; cvxpy-1.9.2-cp312-cp312-win_amd64.whl; cvxpy-1.9.2-cp313-cp313-macosx_10_13_universal2.whl; cvxpy-1.9.2-cp313-cp313-macosx_10_13_x86_64.whl; cvxpy-1.9.2-cp313-cp313-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl; cvxpy-1.9.2-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl; cvxpy-1.9.2-cp313-cp313-win_amd64.whl; cvxpy-1.9.2-cp314-cp314-macosx_10_15_universal2.whl; cvxpy-1.9.2-cp314-cp314-macosx_10_15_x86_64.whl; cvxpy-1.9.2-cp314-cp314-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl; cvxpy-1.9.2-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl; cvxpy-1.9.2-cp314-cp314t-macosx_10_15_universal2.whl
Tags
More Mathematics packages
NetworkX provides data structures and…
permissive · top 1,000 on PyPI
kiwisolverkiwisolver is a Python binding to a fast C++…
permissive · top 1,000 on PyPI
sympySymPy is a Python library for symbolic…
permissive · top 1,000 on PyPI
contourpyContourPy calculates contours of 2D…
permissive · top 1,000 on PyPI
torchPyTorch provides GPU-accelerated tensor…
permissive · top 1,000 on PyPI
onnxruntimeonnxruntime loads and executes Open Neural…
permissive · top 1,000 on PyPI
cobraCOBRApy is a constraint-based modeling package…
copyleft · top 15,000 on PyPI
cvxpy-basecvxpy-base provides compiled solver kernels for…
permissive · top 15,000 on PyPI
pyomoPyomo is a Python framework for formulating and…
permissive · top 5,000 on PyPI
qpsolversProvides a unified Python interface to solve…
copyleft · top 5,000 on PyPI
ropwrRoPWR computes optimal piecewise polynomial…
permissive · top 15,000 on PyPI
aimmspyaimmspy provides Python bindings to run AIMMS…
permissive · top 15,000 on PyPI
ecosECOS is a Python wrapper for a numerical solver…
copyleft · top 5,000 on PyPI
highspyHighspy is a Python wrapper around HiGHS, a…
permissive · top 5,000 on PyPI
clarabelClarabel is an interior-point conic…
permissive · top 5,000 on PyPI
scsscs is a Python interface to the Splitting…
permissive · top 5,000 on PyPI