Registry / ai-ml / gekko
library1.3.2pypypi✓ verified 86d ago

GEKKO is a Python package for machine learning and optimization of mixed-integer and differential algebraic equations (DAE) systems, coupled with large-scale solvers for various programming types (LP, QP, NLP, MILP, MINLP). It provides an object-oriented interface to the APMonitor optimization suite, supporting modes like parameter regression, dynamic data reconciliation, real-time optimization, dynamic simulation, and nonlinear predictive control. Currently at version 1.3.2, GEKKO is actively maintained with frequent releases and consistently sees over 100,000 downloads per month.

pip install gekko
INSTALL
IMPORT
SIG · GEKKO
G
gekko
ai-mlpythonv1.3.2
Install
3.8s avg
Import
354ms
Disk
123MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.3.2 · 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.910 runs
installs and imports cleanly · install 0.0s · import 0.350s · 123.6MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 3.8s · import 0.357s · 120MB
123MB installed
● package 123MB
Code
Verified usage

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

GEKKO
from gekko import GEKKO

This quickstart defines a simple nonlinear programming (NLP) problem with two variables, two constraints, and an objective function. It initializes a GEKKO model, sets up the variables, equations, and objective, and then solves the problem, printing the optimal variable values and objective function value.

from gekko import GEKKO m = GEKKO() # Initialize model # Define variables with initial guess and bounds x = m.Var(value=1, lb=0, ub=4) y = m.Var(value=1, lb=0, ub=4) # Define equations (constraints) m.Equation(x + y == 3) m.Equation(x**2 + y**2 >= 5) # Define objective function (to minimize) m.Minimize((x-2)**2 + (y-1)**2) # Solve the optimization problem m.solve(disp=False) # disp=False suppresses solver output # Print results print(f"Optimal Solution: x = {x.value[0]}, y = {y.value[0]}") print(f"Optimal Objective: {m.options.objfcnval}")
gekko --version
Debug
Known issues
breakingThe default behavior for solving models changed from remote (cloud server) to local execution (`remote=False`). Users accustomed to models running on public servers will now have models solve locally by default.
fix
To explicitly use the public server for solving, initialize the model with `m = GEKKO(remote=True)`.
affects: >=1.3.1
gotchaWhen defining equations or objective functions, use GEKKO's symbolic math operations (e.g., `m.exp()`, `m.sin()`) rather than standard Python `math` or `numpy` functions directly on GEKKO variables. GEKKO performs automatic differentiation, which requires its internal representations.
fix
Replace `math.exp(x)` or `np.sin(y)` with `m.exp(x)` or `m.sin(y)` where `x` and `y` are GEKKO variables. Direct use of `math` or `numpy` functions will typically result in `AttributeError` or `TypeError`.
affects: All versions
gotchaLocal solver availability and performance can vary by operating system and architecture. Some advanced solvers (like IPOPT for Linux/macOS) are often only available via the `remote=True` option due to distribution size or licensing restrictions.
fix
If experiencing solver issues or needing specific solvers, consider using `m = GEKKO(remote=True)` to leverage the public server, or consult GEKKO documentation for specific local solver bundles for your OS/architecture.
affects: All versions
gotchaComplex models with many equations or variables can encounter a 'Max Equation Length' error, indicating the model is too large for the current configuration.
fix
Simplify your model by reducing variables or equations, splitting the problem into sub-problems, or using a remote server (`remote=True`) which might have increased limits. You may also need to check model formulation for redundant expressions.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'gekko'
The GEKKO library is not installed in the current Python environment.
fix
Run `pip install gekko` in your terminal or environment.
Exception: @error: Solution Not Found. Check model formulation and solver options.
The solver failed to find a feasible solution or reached maximum iterations. This could be due to an ill-posed problem, infeasible constraints, poor initial guesses, or solver limitations.
fix
Examine `m.options.APPSTATUS` and `m.options.APPINFO` for specific error codes. Try different initial values for variables, relax constraints, or switch to a different solver (`m.options.SOLVER = 1` for APOPT, `3` for IPOPT if available). Set `m.options.DEBUG=1` or `disp=True` during `m.solve()` for more verbose output.
AttributeError: 'GEKKO' object has no attribute 'exp' (or 'sin', 'log', etc.) TypeError: object of type 'int' has no len() (or similar with numpy/math functions)
Attempting to use standard Python `math` or `numpy` functions directly on GEKKO symbolic variables. GEKKO variables require GEKKO's own symbolic operations for automatic differentiation.
fix
Replace `math.function(m.Var)` or `np.function(m.Var)` with `m.function(m.Var)`. For example, use `m.exp(x)` instead of `math.exp(x)`.
GEKKO: Invalid APM server or file. Check if 'apm.exe' (Windows), 'apm' (Linux), 'apm_mac' (MacOS) exists in C:\Users\...\AppData\Local\Temp\...
GEKKO is configured for a local solve (`remote=False`), but the necessary APM solver executables are missing or cannot be found in the specified temporary directory or system PATH.
fix
Ensure GEKKO is correctly installed and its executables are present. If running on an unsupported architecture for local solve, or if executables are corrupted, consider using `m = GEKKO(remote=True)` to offload solving to the public server. Reinstalling GEKKO (`pip install --upgrade gekko`) might also resolve missing executables.
Upgrade
Version history
1.3.2latest on PyPI · released Dec 31, 2025
Audit
Dependencies
numpyrequiredUsed for numerical operations and often implicitly required for data handling.
pyomooptionalOptional extension for interfacing with Pyomo models.
gpflowoptionalOptional integration for Gaussian Process Regression (GPR) models in ML module.
scikit-learnoptionalOptional integration for various tree-based and other ML models.
Agent activity
7 hits · last 30 days
node
6
OpenAI (training)
1
Resources
gekko — pip install gekko · libregistry