Registry / data / cvxpy-base

cvxpy-base

JSON →
library1.9.1pypypi✓ verified 90d ago

CVXPY is a domain-specific language (DSL) for modeling convex optimization problems in Python. The `cvxpy-base` package provides the core functionality without bundling default solvers. It is currently at version 1.8.2 and follows a regular release cadence with major versions released periodically and patch releases for bug fixes and solver updates.

pip install cvxpy-base
INSTALL
IMPORT
SIG · CVXPY-BASE
C
cvxpy-base
datapythonv1.9.1
Install
9.3s avg
Import
2864ms
Disk
526MB
Pass rate
5/ 10
Env Coverage5 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v1.7.5 · 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
py 3.10–3.920 runs
build_error
glibc
py 3.10–3.920 runs
installs and imports cleanly · install 9.3s · import 2.864s · 465MB
526MB installed
● package 526MB
Code
Verified usage

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

cp
✓ import cvxpy as cp
✗ from cvxpy import Problem, Variable, Minimize
While direct imports work, 'import cvxpy as cp' is the canonical and recommended alias for clarity and consistency in the CVXPY ecosystem.

This example demonstrates how to define variables, an objective function, and constraints to form a convex optimization problem using CVXPY. It then attempts to solve it, highlighting the necessity of having a solver installed, especially when using `cvxpy-base`.

import cvxpy as cp import numpy as np # Define variables x = cp.Variable() y = cp.Variable() # Define objective function objective = cp.Minimize((x - y)**2 + 1) # Define constraints constraints = [x + y >= 0, x - y >= 0, x <= 3] # Formulate the problem problem = cp.Problem(objective, constraints) # Solve the problem (requires a solver to be installed) try: problem.solve() if problem.status == cp.OPTIMAL or problem.status == cp.OPTIMAL_INACCURATE: print(f"Problem status: {problem.status}") print(f"Optimal value: {problem.value:.4f}") print(f"Optimal x: {x.value:.4f}") print(f"Optimal y: {y.value:.4f}") else: print(f"Problem did not solve to optimality. Status: {problem.status}") except cp.error.SolverError as e: print(f"Solver Error: {e}") print("\nHint: To solve problems with `cvxpy-base`, you must install a compatible solver separately. ") print("For example: `pip install ecos` or `pip install osqp`. ") print("Alternatively, install the full `cvxpy` package: `pip install cvxpy`.") except Exception as e: print(f"An unexpected error occurred: {e}")
Debug
Known issues
gotchaThe `cvxpy-base` package only contains the core library and does NOT include any default solvers. Users installing `cvxpy-base` will need to manually install compatible solvers (e.g., `ecos`, `osqp`, `scs`) for problem solving.
fix
For most users, it is recommended to install the full `cvxpy` package via `pip install cvxpy`, which bundles common open-source solvers. If using `cvxpy-base`, install solvers explicitly: `pip install ecos osqp scs`.
affects: All versions
breakingCVXPY 1.8.x and newer versions have updated Python support, requiring Python 3.11 through 3.14. Older Python versions (e.g., 3.9, 3.10) are no longer officially supported.
fix
Upgrade your Python environment to version 3.11 or newer. For projects requiring older Python, use CVXPY 1.7.x or older (which are no longer supported with bugfixes).
affects: >=1.8.0
gotchaCVXPY is designed for *convex* optimization problems. Attempting to solve a non-convex problem will often result in a `DCPError`.
fix
Review the problem formulation to ensure it satisfies the rules of Disciplined Convex Programming (DCP). If the problem is inherently non-convex, CVXPY is not the right tool, and you should look for non-convex optimization libraries.
affects: All versions
Errors
Common errors & fixes
cvxpy.error.SolverError: Either candidate solvers are not installed or cannot handle the problem.
The `cvxpy-base` package does not include any solvers by default, and no compatible solver was found in your Python environment to handle the specified problem type.
fix
Install one or more compatible solvers. For example, `pip install ecos` or `pip install osqp`. For a common set of open-source solvers, install the full `cvxpy` package: `pip install cvxpy`.
cvxpy.error.DCPError: Problem does not satisfy DCP rules.
The mathematical expression defined for the objective or constraints violates the rules of Disciplined Convex Programming (DCP), meaning CVXPY cannot guarantee its convexity.
fix
Carefully review the objective function and constraints to ensure they are convex and adhere to CVXPY's DCP rules. Consult the CVXPY documentation on DCP rules for guidance.
AttributeError: 'float' object has no attribute 'is_atom'
You are attempting to use a raw Python float or NumPy array in a context where CVXPY expects an `Expression`, `Variable`, or `Parameter` object, often within an atom or constraint definition.
fix
Ensure all mathematical operations within CVXPY objectives and constraints are performed using CVXPY objects. For example, convert constants to `cp.Constant(value)` if they are part of complex expressions, or ensure variables are correctly initialized as `cp.Variable()`.
Upgrade
Version history
1.9.1latest on PyPI · released May 26, 2026
Audit
Dependencies
numpyrequiredCore numerical operations and array handling.
scipyrequiredScientific computing utilities, often used for sparse matrices and linear algebra.
ecosoptionalA common cone solver, required for many problems. Not included with `cvxpy-base`.
osqpoptionalAn operator splitting solver for quadratic programs. Not included with `cvxpy-base`.
scsoptionalA splitting cone solver. Not included with `cvxpy-base`.
Agent activity
24 hits · last 30 days
node
22
OpenAI (training)
1
Resources
cvxpy-base — pip install cvxpy-base · libregistry