Install & Compatibility
Where this runs
tested against v22.2.0.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
muslpy 3.10–3.95 runs
build_error
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 3.9s · import 0.096s · 48MB
47MB installed
● package 47MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
Cplex
✓ from cplex import Cplex
✗ import cplex (then using cplex.Cplex())
Using `import cplex` then `cplex.Cplex()` also works but is less common.
Solves a simple LP: minimize x + 2y subject to x + y = 1, x,y >= 0.
import cplex
from cplex.exceptions import CplexError
prob = cplex.Cplex()
prob.set_problem_name("example")
prob.objective.set_sense(prob.objective.sense.minimize)
# Add variables
names = ["x", "y"]
obj = [1.0, 2.0]
lb = [0.0, 0.0]
ub = [cplex.infinity, cplex.infinity]
prob.variables.add(obj=obj, lb=lb, ub=ub, names=names)
# Add constraint: x + y == 1
prob.linear_constraints.add(
lin_expr=[cplex.SparsePair(ind=["x", "y"], val=[1.0, 1.0])],
senses=["E"],
rhs=[1.0]
)
prob.solve()
print("Solution status:", prob.solution.get_status())
print("x =", prob.solution.get_values("x"))
print("y =", prob.solution.get_values("y"))
Debug
Known issues
breakingCPLEX 22.1 dropped Python 3.6/3.7 support. Requires Python >=3.9.fixUpgrade Python to 3.9+ or downgrade CPLEX to 20.1 (which supports Python 3.6-3.8).
affects: >=22.1
gotchaCPLEX Community Edition limits model size to 1000 variables and 1000 constraints. Attempting larger models raises CplexError.fixUse the full (non-community) licensed version for larger models.
affects: all (Community Edition)
gotchaConcurrent use of multiple Cplex instances is not thread-safe. Avoid creating Cplex objects in multiple threads without synchronization.fixUse multiprocessing (processes) instead of threading for parallel solves.
affects: all
deprecatedCPLEX 12.10 deprecated `cplex.callbacks` in favor of the CPLEX Callback API (C-type callbacks). Python interface updated accordingly.fixUse `problem.register_callback()` with the new callback classes (e.g., `cplex.callbacks.IncumbentCallback`).
affects: >=12.10
Errors
Common errors & fixes
CplexError: CPLEX Error 1001: Out of memory.
Model too large for Community Edition (1000x1000 limit) or system memory exhausted.
fixReduce model size (Community cap) or use licensed CPLEX; if memory, simplify model or increase swap.
ModuleNotFoundError: No module named 'cplex'
cplex package not installed or installed in wrong Python environment.
fixRun `pip install cplex` in the current environment (e.g., conda, virtualenv).
ImportError: libcplex2212.so: cannot open shared object file: No such file or directory
CPLEX dynamic library not in library path (Linux) – typically due to missing CPLEX installation from IBM.
fixInstall CPLEX from IBM site (requires installer) or use pip version (includes binaries for common platforms). For pip version, ensure environment variable LD_LIBRARY_PATH includes site-packages/cplex.
CplexSolverError: CPLEX Error 1217: No solution exists.
Problem is infeasible or unbounded.
fixCheck constraints and bounds; use `problem.feasopt()` to diagnose infeasibility.
Upgrade
Version history
22.2.0.0latest on PyPI · released May 26, 2026
Audit
Dependencies
docplexoptionalHigh-level modeling wrapper (optional but recommended for most users; cplex alone is low-level)