[GNC] gnucash-env for python scripts (GnuCash 3.7)
Geert Janssens
geert.gnucash at kobaltwit.be
Sun Nov 10 14:36:28 EST 2019
Op zondag 10 november 2019 18:42:12 CET schreef CB:
> Short question: Where to find 'gnucash-env' to run python scripts? All
> python examples suggests following:
>
> # Invoke this script like the following example
> # $ gnucash-env python account_analysis.py gnucash_file.gnucash \
> # 2010 1 monthly 12 \
> # debits-show credits-show Assets 'Test Account'
>
That info is outdated. gnucash-env has been removed and shouldn't be needed
anymore.
>
> Long question: I am unable to successfully run example python scripts. Any
> help would be greatly appreciated. I am including details below - apologies
> for long email.
>
> I have built GnuCash 3.7 on my linux computer with python bindings and am
> able to use gnucash executable for general operation through UI. Now, I have
> been trying to use python bindings for some custom analysis in python3. I
> am trying to follow account_analysis.py example from source code. However,
> I am unable to locate 'gnucash-env', which is suggested by the example
> script to invoke it.
>
> Even after adding python3.6/site-packages to PYTHONPATH, I am getting
> following errors. Probably, backend libs are not in path - but I could not
> find any help regarding it.
Do you have more than one gnucash installation on your system ? For example a
2.x version installed via your package manager.
In any case, gnucash is supposed to search for the backend libs relatively to
your python site-packages (it correctly does so on my system), but perhaps
your system lays out its directories differently.
Is there a directory /home/CB/bin/builds/gnucash/build-gnucash-3.7/lib/gnucash
with several libraries whose names start with libgncmod ?
There should be at least a libgncmod-backend-xml.so and libgncmod-
backend.dbi.so.
Regards,
Geert
> Example script:
> https://github.com/Gnucash/gnucash/blob/3.7/bindings/python/example_scripts/
> account_analysis.py
>
> $ python3 gnucash-3.7/bindings/python/example_scripts/account_analysis.py
> '~/tmp/my-accounts.gnucash' 2018 1 monthly 12 debits-show credits-show
> Assets Checking
> * 12:13:23 WARN <gnc.engine> failed to load gncmod-backend-dbi from
> relative path
> * 12:13:23 ERROR <gnc.engine> required library gncmod-backend-dbi not found.
> * 12:13:23 WARN <gnc.engine> failed to load gncmod-backend-xml from
> relative path
> * 12:13:23 ERROR <gnc.engine> required library gncmod-backend-xml not found.
> Traceback (most recent call last):
> File "gnucash-3.7/bindings/python/example_scripts/account_analysis.py",
> line 276, in <module>
> if __name__ == "__main__": main()
> File "gnucash-3.7/bindings/python/example_scripts/account_analysis.py",
> line 176, in main
> gnucash_session = Session(gnucash_file, is_new=False)
> File
> "/home/CB/bin/builds/gnucash/build-gnucash-3.7/lib/python3.6/site-packages/g
> nucash/gnucash_core.py", line 107, in __init__
> self.begin(book_uri, ignore_lock, is_new, force_new)
> File
> "/home/CB/bin/builds/gnucash/build-gnucash-3.7/lib/python3.6/site-packages/g
> nucash/gnucash_core.py", line 153, in new_function
> self.raise_backend_errors(function.__name__)
> File
> "/home/CB/bin/builds/gnucash/build-gnucash-3.7/lib/python3.6/site-packages/g
> nucash/gnucash_core.py", line 131, in raise_backend_errors
> errors )
> gnucash.gnucash_core.GnuCashBackendException: call to begin resulted in the
> following errors, ERR_BACKEND_NO_HANDLER
>
>
>
> I also tried running the tests and found similar errors in LastTest.log,
> although it reported "Test Passed" for sqlite3test and python-bindings. See
> below for details:
>
>
> 125/126 Testing: sqlite3test
> 125/126 Test: sqlite3test
> Command: "/home/CB/bin/builds/gnucash/build-gnucash-3.7/bin/sqlite3test"
> Directory: /home/CB/bin/builds/gnucash/build-gnucash-3.7/bindings/python
> "sqlite3test" start time: Nov 07 20:47 EST
> Output:
> ----------------------------------------------------------
> * 20:47:28 WARN <gnc.engine> failed to load gncmod-backend-dbi from
> relative path
> * 20:47:28 ERROR <gnc.engine> required library gncmod-backend-dbi not found.
> * 20:47:28 WARN <gnc.engine> failed to load gncmod-backend-xml from
> relative path
> * 20:47:28 ERROR <gnc.engine> required library gncmod-backend-xml not found.
> <end of output>
> Test time = 0.01 sec
> ----------------------------------------------------------
> Test Passed.
> "sqlite3test" end time: Nov 07 20:47 EST
> "sqlite3test" time elapsed: 00:00:00
> ----------------------------------------------------------
>
> 126/126 Testing: python-bindings
> 126/126 Test: python-bindings
> Command: "/usr/bin/python3"
> "/home/CB/bin/builds/gnucash/gnucash-3.7/bindings/python/tests/runTests.py.i
> n" Directory:
> /home/CB/bin/builds/gnucash/build-gnucash-3.7/bindings/python/tests
> "python-bindings" start time: Nov 07 20:47 EST
> Output:
> ----------------------------------------------------------
> * 20:47:28 WARN <gnc.core-utils> no backend loaded, or the backend doesn't
> define register_cb, returning 0
> * 20:47:28 WARN <gnc.core-utils> no backend loaded, or the backend doesn't
> define register_cb, returning 0
> * 20:47:28 WARN <gnc.core-utils> no backend loaded, or the backend doesn't
> define register_cb, returning 0
> * 20:47:28 WARN <gnc.core-utils> no backend loaded, or the backend doesn't
> define register_cb, returning 0
> * 20:47:28 WARN <gnc.core-utils> no backend loaded, or the backend doesn't
> define register_cb, returning 0
> ...........................................
> ----------------------------------------------------------------------
> Ran 43 tests in 0.173s
>
> OK
> <end of output>
> Test time = 0.32 sec
> ----------------------------------------------------------
> Test Passed.
> "python-bindings" end time: Nov 07 20:47 EST
> "python-bindings" time elapsed: 00:00:00
> ----------------------------------------------------------
>
>
>
> --
> Sent from: http://gnucash.1415818.n4.nabble.com/GnuCash-User-f1415819.html
> _______________________________________________
> gnucash-user mailing list
> gnucash-user at gnucash.org
> To update your subscription preferences or to unsubscribe:
> https://lists.gnucash.org/mailman/listinfo/gnucash-user
> If you are using Nabble or Gmane, please see
> https://wiki.gnucash.org/wiki/Mailing_Lists for more information. -----
> Please remember to CC this list on all your replies.
> You can do this by using Reply-To-List or Reply-All.
More information about the gnucash-user
mailing list