PyGekko: Gekko Timeseries And Modeling
PyGekko is a Python package for Gekko. Gekko is open-source timeseries-oriented software for handling and analyzing timeseries data, and for solving and analyzing large-scale economic models. You may install the PyGekko package with the following (Windows, Python 3.11-3.13):
pip install pygekko
BEWARE: PyGekko is in its very early stages!
You may for instance use PyGekko like this:
import pygekko as pg
t1 = 2021
t2 = 2023
pg.run("reset;")
pg.run(f"time {t1} {t2};")
pg.run("x1 = 2, 3, 4;")
pg.run("x2 = 7, 5, 6;")
pg.run("y = x1 + x2;")
pg.run("prt x1, x2, x1/y;")
In general, at the moment, you call Gekko through text strings containing Gekko statements, with the run() function. Printed output will be shown in the Python terminal, in this case:
x1 % x2 % x1/y %
2021 2.0000 M 7.0000 M 0.2222 M
2022 3.0000 50.00 5.0000 -28.57 0.3750 68.75
2023 4.0000 33.33 6.0000 20.00 0.4000 6.67
You may open the Gekko help system with pg.run("help;").
Looks
The following is how the Gekko stand-alone application looks. PyGekko does not show the main Gekko window, but can show other windows like plot, decomp, flowgraph, data-trace viewer, etc. As mentioned later on, you may have to end your Python program with a pg.wait() to make the Gekko windows stay open.
Disclaimers
PyGekko is work in progress and quite immature as a package right now. Still, the string-based interface is expected to be stable and work as-is, also in the longer run.
The PyGekko 3.3.1 version corresponds to the official Gekko 3.3.1 version, and moving forwards, these version numbers will match. Note that 'beta' releases for PyGekko are expected, for instance PyGekko 3.3.2b1, signifying work in progress towards an official PyGekko 3.3.2 version (beta versions are not installed by pip install unless the user explicitly asks for it). You may also encounter 'post' releases like 3.3.1.post1, where typically only very minor PyGekko interface problems are addressed.
Requirements
The PyGekko package only works for Python versions 3.11-3.13 under Windows 64-bit (Python 3.11 was released in October 2022). PyGekko uses the Python.NET package under the hood, which only works for Windows and does not yet support Python 3.14 (released in October 2025). PyGekko support for Python < 3.11 could be provided if there is sufficient interest. Windows 32-bit is no longer supported for newer Gekko versions 3.3.x, and hence is not supported for PyGekko either. PyGekko uses the .NET Framework (not .NET Core) with version at least 4.6.1. If a normal Gekko version can run on your Windows 64-bit pc, so should PyGekko (because it uses the same .NET Framework). PyGekko is self-contained regarding Gekko: it works completely independently of any Gekko installation.
Known issues
- It seems there can be some issues regarding scaling of the plot window.
- Loops and conditionals etc. (lines of Gekko code ending with an
end;) cannot be directly transformed into corresponding lines ofpg.run()calls. Using one glued-together string delimited with;'s will work though. - Talking to dataframes (Pandas/Polars etc.) containing timeseries data can be done through csv files, cf. Gekko's
importandexport. Gekko can write Apache Arrow files (export<arrow>) for easy consumption by Pandas/Polars, but cannot read arrow files (yet). (Gekko'spython_runamounts to calling Python from Gekko, and would be bizarre to use in PyGekko). - When you open up Gekko windows like for instance the plot window (example:
pg.run("plot x1, x2, x1/y;"), you may put apg.wait()at the end of your Python program to make the window(s) stay open. Otherwise Python may take these windows down when it finishes its job.
Gekko links
Contributing + source code
See the GitHub repository.
Roadmap
Among other things, it is expected that the string-based interface will gradually be supplemented with a more proper Python-function interface, for instance supplementing the string-based pg.run(f"decomp <{t1} {t2} {op}> qBNP from E_qBNP;") with an in-built pg.decomp() function providing a more Pythonic pg.decomp("qBNP", t=[t1, t2], op=op, from_="E_qBNP").
Regarding Python and PyGekko, see much more details in this roadmap.
More info
Since 2009, Gekko is being used by Danish ministeries, banks, interest groups and universities, for the simulation of economic and energy-related models. It is also used to show and analyze GAMS models. The software runs under Windows (.NET), and is licenced under GNU GPL.
Some features:
- Timeseries-oriented software, with flexible databanks. Suitable data handling/wrangling and modeling, etc.
- Timeseries can be dimensional (so-called array-timeseries). Data-tracing remembers how timeseries are constructed (data lineage).
- Annual, quarters, months, weeks, days and undated frequencies supported. Conversions between these + seasonal correction.
- Other variable types like values, dates, strings, lists, maps and matrices, including many functions dealing with these.
- Dynamically loaded and compiled models, including failsafe mode.
- Gauss and Newton solvers, with ordering and feedback logic. Fair-Taylor or Newton-Fair-Taylor solver for forward-looking models. Any number of simultaneous goals/means possible.
- In-built equation browser, with integrated variable list.
- Decomposition of model equations (including GAMS models), showing contributions. Flowgraphs to show this info, too.
- User-defined functions and procedures, can be stored in libraries.
- Graphics by means of embedded gnuplot
- Interface to Python, R, GAMS and others. Reads/writes file formats like xls, xlsx, prn, csv, tsd, gdx, px, arrow-files. Integrated add-in for Excel.
- Tabelling and menu system, outputting in text, html or Excel
- Open databank format, using (Google) protocol buffers for storage.
- Strict and consistent language syntax (via in-built ANTLR parser), with loops, conditionals etc.
- Used by Statistics Denmark, Ministry of Finance, Ministry for Economic Affairs, Danish Economic Councils, the central bank of Denmark, institutions, universities and more.
- Easy installation by means of a all-inclusive Windows installer, or manually by means of a zip-file with gekko.exe etc.
- Open source. No licenses to compilers etc. -- everything used is C#/.NET (+ gnuplot and x12a). So everything is open-source, and therefore free of charge.
Metadata
Release files for pygekko 3.3.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| pygekko-3.3.4.tar.gz | 26.4 MB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pygekko-3.3.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 54.1 MB
Release files / pygekko-3.3.4.tar.gz
| Download URL | pygekko-3.3.4.tar.gz |
|---|---|
| Size | 26.4 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f7e56b66293cefeb29b46b09938d1b320b4a01518c4f6e12c65394ef31d3408c
|
|
BLAKE2b-256 checksum How to use checksums |
1a50395b3cfd5033d54d9fc1ad4d615860fe1326bee18593a1a81a858bdde145
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.0
|
Release files / pygekko-3.3.4-py3-none-any.whl
| Download URL | pygekko-3.3.4-py3-none-any.whl |
|---|---|
| Size | 27.7 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c5fd52ff06d199ccb984509e013ff6a974c88e7f04c78116831ee76dc5043b89
|
|
BLAKE2b-256 checksum How to use checksums |
1a7e3084e54f612f3338174815c4904f27481270c1d27e0fbc4f9bab8a787cac
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.0
|
Security for pygekko 3.3.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.