Registry / ai-ml / qpsolvers

qpsolvers

JSON →
library4.13.0pypypi✓ verified 26d ago

qpsolvers is a Python library that provides a unified API to various quadratic programming (QP) solvers. It simplifies the process of solving convex QPs by abstracting away solver-specific APIs and matrix format requirements. Currently at version 4.11.0, the library maintains an active development pace with frequent minor releases to integrate new solvers and provide updates for existing ones.

pip install qpsolvers
INSTALL
IMPORT
SIG · QPSOLVERS
Q
qpsolvers
ai-mlpythonv4.13.0
Install
10.3s avg
Import
1599ms
Disk
597MB
Pass rate
4/ 10
Env Coverage4 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v4.13.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
glibc
py 3.10
2/3 runs
✓ 7.83s
py 3.11
1/3 runs
✓ 12.27s
py 3.12
1/3 runs
✓ 12.3s
py 3.13
1/3 runs
2/3 runs
py 3.9
2/3 runs
✓ 8.93s
597MB installed
● package 597MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

solve_qp
✓ from qpsolvers import solve_qp
solve_problem
✓ from qpsolvers import solve_problem
available_solvers
✓ from qpsolvers import available_solvers

This example demonstrates how to define a quadratic programming problem using NumPy arrays and solve it with an available backend solver. It automatically selects 'proxqp' if available, otherwise it tries the first available solver, or prompts the user to install one if no solvers are found. The problem is formulated in the standard quadratic program form.

import numpy as np from qpsolvers import solve_qp, available_solvers # Define the QP problem in standard form: minimize 0.5 * x.T * P * x + q.T * x # subject to G * x <= h, A * x == b, lb <= x <= ub M = np.array([[1., 2., 0.], [-8., 3., 2.], [0., 1., 1.]]) P = M.T @ M # This results in a positive definite matrix q = np.array([3., 2., 3.]) @ M G = np.array([[1., 2., 1.], [2., 0., 1.], [-1., 2., -1.]]) h = np.array([3., 2., -2.]) A = np.array([1., 1., 1.]) b = np.array([1.]) # Try to use a common open-source solver, or fallback if not available solver_to_use = "proxqp" if "proxqp" in available_solvers else available_solvers[0] if available_solvers else None if solver_to_use: print(f"Using solver: {solver_to_use}") x = solve_qp(P, q, G, h, A, b, solver=solver_to_use) print(f"QP solution: {x = }") else: print("No QP solvers found. Please install one, e.g., pip install qpsolvers[proxqp]")
Debug
Known issues
breakingThe `solver` keyword argument became mandatory for `solve_qp` and `solve_ls` functions in v2.0.
fix
Always provide the `solver` keyword argument when calling `solve_qp` or `solve_ls` (e.g., `solve_qp(..., solver="osqp")`).
affects: < 2.0
breakingThe minimum required Python version was bumped to 3.10.
fix
Ensure your Python environment is version 3.10 or newer.
affects: < 4.9.0
breakingThe Gurobi interface was updated to a newer Gurobi API.
fix
If using Gurobi through `qpsolvers`, ensure your Gurobi installation is compatible with the latest `qpsolvers` API. Review Gurobi-specific code for potential incompatibilities.
affects: 4.10.0+
breakingThe PIQP interface was updated to support the new PIQP v0.6.0 API.
fix
If using PIQP, update your PIQP installation to v0.6.0 or newer to ensure compatibility with `qpsolvers` v4.8.0 and later.
affects: 4.8.0+
gotchaStarting from v4.3.0, `pip install qpsolvers` no longer installs any default QP solvers alongside the library. Solvers must be installed separately.
fix
Install `qpsolvers` with optional solver dependencies using extras, e.g., `pip install qpsolvers[open_source_solvers]` or `pip install qpsolvers[osqp]`.
affects: 4.3.0+
gotchaThe cost matrix `P` in a QP problem should always be symmetric. Many solvers assume this property and may return incorrect results if it's not. Some solvers also require `P` to be positive definite.
fix
Explicitly symmetrize your cost matrix `P` (e.g., `P = 0.5 * (P + P.T)`). Check the documentation for your chosen solver regarding its requirements for `P` (positive (semi-)definite).
affects: All versions
gotchaOSQP solver may issue deprecation warnings related to solver status or matrix conversion, particularly with certain versions of OSQP.
fix
These warnings were partially addressed in `qpsolvers` v4.8.2. Ensure you are on the latest `qpsolvers` version and consider updating your OSQP installation to a version known to be compatible to mitigate these warnings.
affects: 4.8.2+
Errors
Common errors & fixes
ValueError: No QP solver found among OSQP, CVXOPT, Gurobi, CPLEX, MOSEK, quadprog, qdldl, ProxQP.
qpsolvers is a wrapper library and does not include the actual QP solvers; at least one backend solver needs to be installed separately.
fix
Install a backend solver, for example OSQP, using `pip install osqp` or `pip install cvxopt` for CVXOPT.
ValueError: P must be a square matrix.
The matrix P (or other input matrices like G, A) provided to `solve_qp` does not meet the expected dimensional requirements, such as P needing to be square (n x n).
fix
Ensure all input matrices and vectors (P, q, G, h, A, b, lb, ub) are correctly shaped NumPy arrays or SciPy sparse matrices according to QP formulation, e.g., P as n x n, q as n-vector.
ModuleNotFoundError: No module named 'qpsolvers.solve_qp'
The `solve_qp` function is directly available within the `qpsolvers` package, not as a submodule, leading to an incorrect import path.
fix
Import the function directly using `from qpsolvers import solve_qp` or import the package and call the function as `qpsolvers.solve_qp(...)`.
ValueError: Unknown OSQP option: 'invalid_option_name'.
An option name or value provided in the `solver_options` dictionary is not recognized or supported by the chosen backend QP solver (e.g., OSQP).
fix
Consult the official documentation for the specific backend solver you are using (e.g., OSQP settings, CVXOPT options) to find the correct option names and accepted values.
Upgrade
Version history
4.13.0latest on PyPI · released Jul 19, 2026
Audit
Dependencies
numpyrequiredCore dependency for numerical operations and array handling.
scipyrequiredNeeded for sparse matrix formats (CSC) and some internal utilities.
clarabeloptionalOptional backend QP solver.
coptoptionalOptional commercial backend QP solver.
cvxoptoptionalOptional backend QP solver.
ecosoptionalOptional backend QP solver.
gurobioptionalOptional commercial backend QP solver.
osqpoptionalOptional backend QP solver.
piqpoptionalOptional backend QP solver.
proxqpoptionalOptional backend QP solver.
quadprogoptionalOptional backend QP solver.
scsoptionalOptional backend QP solver.
Agent activity
14 hits · last 30 days
node
10
Amazon
1
OpenAI (training)
1
Resources
qpsolvers — pip install qpsolvers · libregistry