{"id":9633,"library":"cvxpy-base","title":"CVXPY Base","description":"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.","status":"active","version":"1.8.2","language":"en","source_language":"en","source_url":"https://github.com/cvxpy/cvxpy","tags":["optimization","convex-optimization","mathematical-programming","dsl","linear-programming","quadratic-programming"],"install":[{"cmd":"pip install cvxpy-base","lang":"bash","label":"Install core CVXPY without default solvers"},{"cmd":"pip install cvxpy","lang":"bash","label":"Recommended: Install CVXPY with default solvers (ECOS, OSQP, SCS)"}],"dependencies":[{"reason":"Core numerical operations and array handling.","package":"numpy","optional":false},{"reason":"Scientific computing utilities, often used for sparse matrices and linear algebra.","package":"scipy","optional":false},{"reason":"A common cone solver, required for many problems. Not included with `cvxpy-base`.","package":"ecos","optional":true},{"reason":"An operator splitting solver for quadratic programs. Not included with `cvxpy-base`.","package":"osqp","optional":true},{"reason":"A splitting cone solver. Not included with `cvxpy-base`.","package":"scs","optional":true}],"imports":[{"note":"While direct imports work, 'import cvxpy as cp' is the canonical and recommended alias for clarity and consistency in the CVXPY ecosystem.","wrong":"from cvxpy import Problem, Variable, Minimize","symbol":"cp","correct":"import cvxpy as cp"}],"quickstart":{"code":"import cvxpy as cp\nimport numpy as np\n\n# Define variables\nx = cp.Variable()\ny = cp.Variable()\n\n# Define objective function\nobjective = cp.Minimize((x - y)**2 + 1)\n\n# Define constraints\nconstraints = [x + y >= 0, x - y >= 0, x <= 3]\n\n# Formulate the problem\nproblem = cp.Problem(objective, constraints)\n\n# Solve the problem (requires a solver to be installed)\ntry:\n    problem.solve()\n    if problem.status == cp.OPTIMAL or problem.status == cp.OPTIMAL_INACCURATE:\n        print(f\"Problem status: {problem.status}\")\n        print(f\"Optimal value: {problem.value:.4f}\")\n        print(f\"Optimal x: {x.value:.4f}\")\n        print(f\"Optimal y: {y.value:.4f}\")\n    else:\n        print(f\"Problem did not solve to optimality. Status: {problem.status}\")\nexcept cp.error.SolverError as e:\n    print(f\"Solver Error: {e}\")\n    print(\"\\nHint: To solve problems with `cvxpy-base`, you must install a compatible solver separately. \")\n    print(\"For example: `pip install ecos` or `pip install osqp`. \")\n    print(\"Alternatively, install the full `cvxpy` package: `pip install cvxpy`.\")\nexcept Exception as e:\n    print(f\"An unexpected error occurred: {e}\")","lang":"python","description":"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`."},"warnings":[{"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`.","message":"The `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.","severity":"gotcha","affected_versions":"All versions"},{"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).","message":"CVXPY 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.","severity":"breaking","affected_versions":">=1.8.0"},{"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.","message":"CVXPY is designed for *convex* optimization problems. Attempting to solve a non-convex problem will often result in a `DCPError`.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"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`.","cause":"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.","error":"cvxpy.error.SolverError: Either candidate solvers are not installed or cannot handle the problem."},{"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.","cause":"The mathematical expression defined for the objective or constraints violates the rules of Disciplined Convex Programming (DCP), meaning CVXPY cannot guarantee its convexity.","error":"cvxpy.error.DCPError: Problem does not satisfy DCP rules."},{"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()`.","cause":"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.","error":"AttributeError: 'float' object has no attribute 'is_atom'"}]}