_ _ ___ | | | | / | __ _ _ __ ___| |_| |/ /| |_ __ _ _ / _` | '__/ _ \ __| / /_| | '_ \| | | | | (_| | | | __/ |_| \___ | |_) | |_| | \__, |_| \___|\__|_| |_/ .__/ \__, | __/ | | | __/ | |___/ |_| |___/
gretl4py is a Python package designed to meet the needs of econometricians and applied economists who wish to use Python in their research. It can be broadly viewed as a complement to the statsmodels package, with a more specific orientation toward the inference methods commonly employed in applied economics.
gretl4py provides an interface to libgretl for the Python language (versions 3.11, 3.12, and 3.13 have been tested). Libgretl is the underlying engine for the gretl program. At present, the focus is mainly on the APIs implementing estimation methods, but a broader range of features is planned.
gretl4py consists of the following elements:
Source code (git repository): source, official PyPI page: gretl4py.
Before installing gretl4py, please ensure the following components are installed:
Linux users may encounter security warnings when installing non-system Python packages. This affects distributions such as Debian/Ubuntu and Arch. To comply with these restrictions, you can run the webinstall.py script available here. This script downloads a wheel package from the SourceForge website and installs it locally.
Instructions can be found in section 2.3 of the gretl4py documentation. Besides a C++ compiler with support for the C++17 standard, you'll need the following development packages for gretl 2025b or later:
Note that we are using the Meson build system.
You can find numerous sample *.py files in the demo and examples subdirectories of gretl4py. These files can be examined in any suitable text editor. Starting from the gretl4py directory, one way to explore the package is:
cd demo python3 estimators.py
(Substitute python.exe for python3 on Windows.) You can also run gretl4py interactively. Start the Python interpreter and type import gretl. In addition to regular Python commands, you can call any of the functions described in the gretl4py documentation.
The PDF documentation contains many more details about the gretl4py module, including a listing of the available APIs and several usage examples.
Marcin Błażejowski, marcin(at)gretlconference(dot)org
Last updated: 2025-06-09