Chapter 17. Python Bindings

GnuCash historically has always been a traditional application in the sense that you open it, use it to manipulate your financial data via the windows it presents, save your data and close the windows again. This has the inherent limitation that you can only do whatever the windows, menus and toolbars allow you to do.

Sometimes you might need a little more flexibility. For example, you need a report with just a little different information than what the built-in reports provide, or you want to automate a frequently recurring action. Such custom manipulations are ideal candidates to write in one or the other scripting language.

Starting with GnuCash version 2.4 you can write Python scripts to manipulate your financial data.

Important

The Python extensions are an optional feature which creates additional dependencies. To be able to use Python scripts, GnuCash must have been built with the cmake -DWITH_PYTHON=ON … option enabled, otherwise all what follows won’t work. At present this option is not enabled by default, so if you need this, you may have to compile GnuCash from source yourself. But some distributions offer it also as a separate package with a name like python[version]-GnuCash

The Python extensions come with a couple of ready to use scripts. This chapter will show you how to use some of them.

Tip

This chapter is not about how to write your own Python scripts. Refer to the developer documentation for that instead.