[GNC] gnucash-env for python scripts (GnuCash 3.7)

CB chitresh4u at gmail.com
Sun Nov 10 12:42:12 EST 2019


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'


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.
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/gnucash/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/gnucash/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/gnucash/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.in"
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


More information about the gnucash-user mailing list