[GNC] Python bindings issue

Jim DeLaHunt list+gnucash at jdlh.com
Wed Aug 14 14:31:23 EDT 2024


On 2024-08-14 10:56, Gere Kiss Zsolt wrote:
> Hi Jim,
>
> Did you succeed to import the Python bindings with  `import gnucash`?
>
> On Wed, 14 Aug 2024 at 02:16, Jim DeLaHunt<list+gnucash at jdlh.com>  wrote:
>> That has succeeded sometimes, and failed sometimes, but presently it
>> succeeds.
>
> Could this happen because the book was sometimes locked ? (just a question)

Not that I observed. When it failed, I think it was because of bugs in 
the GnuCash build process, either in MacPorts or when I built GnuCash 
from source.

> Thanks for the code bits. You helped me in the way that it made clear that
> gnucash bindings work with Python 3.11. So I decided to give it a try.
>
> As I said, I have Ubuntu 22.04 on my system. This did not seem old to me,
> but it is ~2 years old, and the last LTS version is 24.04. That comes with
> Python 3.12 and packaged with GnuCash 5.5. I tried those and voila: *it
> worked*!

The obvious next question: when you installed the `python3-gnucash` 
package on your system, where exactly did it install its .py files?

On MacPorts, I can find out where the `gnucash` port installed its 
Python files by means of:

% port contents gnucash | grep Python
   /opt/local/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/gnucash/__init__.py
   ...[other paths elided]...

The `Versions/3.11` part of the path is a clue that the `gnucash` port 
installed its Python files in Python 3.11, rather than the other several 
versions of Python on my system.

Maybe there is a similar command you can use on your system to find out 
a) if you have multiple copies of the Python interpreter on your 
computer, b) if you have multiple locations where Python modules could 
be installed, and c) into which location the `python3-gnucash` package 
actually installed its Python modules.

I'm glad to hear that you found a combination which worked.

Best regards,
      —Jim DeLaHunt



More information about the gnucash-user mailing list