Registry / data / pyscipopt

pyscipopt

JSON →
library6.2.1pypypi✓ verified 87d ago

PySCIPOpt is a Python interface and modeling environment for the SCIP Optimization Suite, a powerful mixed-integer programming (MIP) and mixed-integer nonlinear programming (MINLP) solver. It allows users to formulate and solve optimization problems using Python syntax. The library is actively maintained with frequent releases, often coinciding with new major versions of the underlying SCIP solver.

pip install pyscipopt
INSTALL
IMPORT
SIG · PYSCIPOPT
P
pyscipopt
datapythonv6.2.1
Install
4.2s avg
Import
291ms
Disk
140MB
Pass rate
5/ 10
Env Coverage5 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v6.2.1 · 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.103.920 runs
build_error
glibc
py 3.103.920 runs
installs and imports cleanly · install 4.2s · import 0.291s · 138MB
140MB installed
● package 140MB
Code
Verified usage

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

Model
from pyscipopt import Model

This quickstart demonstrates how to create a simple linear programming model, add variables, define an objective function, add constraints, optimize the model, and retrieve the solution. It also shows how to check the optimization status and explicitly free problem data.

from pyscipopt import Model, SCIP_STATUS # Create a SCIP model model = Model("Simple_LP") # Add variables x = model.addVar("x", vtype="CONTINUOUS", lb=0.0) y = model.addVar("y", vtype="CONTINUOUS", lb=0.0) # Set the objective function: Maximize x + 2y model.setObjective(x + 2*y, "maximize") # Add constraints model.addCons(x + y <= 10, "c1") model.addCons(2*x + y <= 15, "c2") # Optimize the model model.optimize() # Check the solution status and print results if model.getStatus() == SCIP_STATUS.OPTIMAL: print(f"Optimal solution found.") print(f"Objective value: {model.getObjVal()}") print(f"x: {model.getVal(x)}") print(f"y: {model.getVal(y)}") else: print(f"Problem could not be solved to optimality. Status: {model.getStatus()}") # Clean up the model (important for repeated modifications/solves) model.freeProb()
Debug
Known issues
breakingPySCIPOpt v6.0.0 introduced compatibility with SCIP 10, which includes significant changes to the underlying SCIP solver. This update removed some old methods (e.g., `chgAndConsCheckFlagWhenUpgr`, `chgAndConsRemovableFlagWhenUpgr`) and changed how nonlinear constraints are handled internally, which may affect existing code relying on older SCIP versions or specific API calls.
fix
Review the `CHANGELOG.md` for v6.0.0 and SCIP 10 release notes. Update code to use new features like IIS and exact solving, and adjust any deprecated or removed API calls.
affects: >=6.0.0
gotchaModifying a model after it has been optimized without calling `freeTransform()` can lead to unexpected crashes or incorrect behavior. SCIP retains transformed problem data by default.
fix
Always call `model.freeTransform()` before attempting to modify variables, constraints, or the objective of an already optimized model. For a full cleanup, use `model.freeProb()`.
affects: <6.1.0
gotchaAccessing dual values from the solution can be unreliable in default SCIP configurations. Accurate dual values are only guaranteed when presolving, propagation, and primal heuristics are disabled, and the problem has no bound constraints.
fix
If precise dual values are critical, set appropriate SCIP parameters to disable presolving, propagation, and heuristics (e.g., `model.setParam('presolving/maxrounds', 0)`, `model.setParam('relaxing/maxrounds', 0)`, `model.setParam('heuristics/activated', 'off')`). Refer to SCIP documentation for specific parameters.
affects: All versions
gotchaPython's operator overloading does not support chained comparisons for ranged constraints (e.g., `lhs <= expr <= rhs`). This syntax will not work as expected in PySCIPOpt.
fix
For ranged constraints, explicitly parenthesize the expression: `model.addCons(lhs <= (expression <= rhs), "cons_name")`. Alternatively, add single-sided constraints and modify bounds later using `chgRhs` or `chgLhs`.
affects: All versions
gotchaPrior to v4.4.0, PySCIPOpt did not bundle the SCIP Optimization Suite. Installation via pip or source for older versions required manual installation of SCIP and setting the `SCIPOPTDIR` environment variable to point to its installation. Newer versions typically bundle SCIP, but this variable might still be needed for custom builds or specific environments.
fix
For older versions, or if experiencing `scip/scip.h` not found errors, install the SCIP Optimization Suite separately and set the `SCIPOPTDIR` environment variable to its base directory before installing PySCIPOpt.
affects: <4.4.0 (and custom builds)
Errors
Common errors & fixes
Failed building wheel for pyscipopt / Cannot open include file: 'scip/scip.h': No such file or directory
This typically occurs during installation when the underlying SCIP Optimization Suite development files are not found or linked correctly, especially in environments where SCIP is not bundled or `SCIPOPTDIR` is not set.
fix
Ensure you have the SCIP Optimization Suite installed. If not bundled by PySCIPOpt (versions < 4.4.0) or for source builds, manually install SCIP and set the environment variable `SCIPOPTDIR` to the base directory of your SCIP installation (e.g., `export SCIPOPTDIR=/path/to/SCIPOptSuite`). Then retry `pip install pyscipopt`.
ModuleNotFoundError: No module named 'pyscipopt'
The `pyscipopt` package was either not installed, installed in a different Python environment, or the current environment is not activated.
fix
Run `pip install pyscipopt` (preferably within a virtual environment) or activate the correct Python environment where it was installed.
Segmentation fault / Crash when modifying model after optimization
Changes were attempted on the model (e.g., adding variables/constraints) after an `optimize()` call without properly resetting the model's internal state.
fix
Call `model.freeTransform()` before making any modifications to the model after it has been optimized. For a full reset, use `model.freeProb()`.
TypeError: unsupported operand type(s) for <: 'int' and 'Expr'
Incorrect syntax used for defining ranged constraints, attempting `lhs <= expression <= rhs` directly.
fix
Use explicit parentheses for ranged constraints: `model.addCons(lhs <= (expression <= rhs))`.
Upgrade
Version history
6.2.1latest on PyPI · released May 16, 2026
Audit
Dependencies
pythonrequiredRequired Python version.
SCIP Optimization SuiteoptionalPySCIPOpt is an interface to the SCIP solver. For versions 4.4.0 and newer, SCIP is bundled, but specific configurations (e.g., building from source, certain OS/Python combinations) might require a separate installation and linking.
Agent activity
15 hits · last 30 days
node
12
Amazon
1
OpenAI (training)
1
Resources
pyscipopt — pip install pyscipopt · libregistry