ParIT's package and Python bindings examples?
Mike Evans
mikee at saxicola.idps.co.uk
Sat Sep 18 05:57:44 EDT 2010
On Friday September 17 2010 22:28:52 ... wrote:
> Finally think I have gnucash 2.2.9 built on my ubuntu 9.04 machine. But, i
> am not sure that the python bindings included with it are workable. I was
> not able to execute sample code.
>
> Used
>
> http://www.parit.ca/products/finance/apt-repository
>
> used
> sudo apt-get install gnucash
> sudo apt-get source gnucash
>
> found modules in /usr/lib/python2.5/site-packages/gnucash/ which is
> already in my path.
>
> But i did not find any example code in the unpacked source
> (/home/elliot/gnucash-2.2.9/src/optional/python bindings/) I downloaded an
> example linked to from the gnucash wiki
>
> http://svn.gnucash.org/trac/browser/gnucash/trunk/src/optional/python-bindi
> ngs/example_scripts
>
> So i have executable code from ParIT's site and a python example from the
> gnucash repo (which i was unable to build)
>
> I copied the execute statement from the description in
> simple_business_create.py to the shell and executed it. Did not work. I
> know that the PYTHONPATH is correct because previously I was accidentally
> using my python2.6 executable, which does not have the gnucash modules in
> its PYTHONPATH and the error was like "cannot find gnucash". The error
> below is better (it found gnucash but couldn't find a specific detail)
>
>
> elbiot at elbitop:/usr/lib/python2.5/site-packages/gnucash$ gnucash-env
> /usr/bin/python2.5 /home/elbiot/Desktop/tmp/simple_business_create.py
> sqlite3:///home/blah/blah.gnucash
> Traceback (most recent call last):
> File "/home/elbiot/Desktop/tmp/simple_business_create.py", line 41, in
> <module>
> from gnucash.gnucash_business import Customer, Employee, Vendor, Job, \
> ImportError: cannot import name Job
>
> I deleted all referances to Job and got "Cannot import Invoice" next.
>
> so:
>
> 1) can I/ should I use the ParIT package to begin working with the python
> bindings? Perhaps it just has a slightly reduced set of non-critical
> functions but still works and has functionality.
>
> 2) if so, where can I find an example that will work with this build? Or
> do I need to keep deleting portions of example code from trunk until I
> find what functions I have access to?
>
> 3) is there a manual work around,like copying the python source from trunk
> into my python path, and by that get access to Job, Invoice and whatever
> else. Or are there changes to the compiled gnucash that need to accompany
> the existence of new objects in the interpreted python code.
>
> ( re #3: Despite my better judgement but because I have two different
> python executables with different paths, I copied trunk's python code from
> http://svn.gnucash.org/trac/browser/gnucash/trunk/src/optional/python-bind
> ingsto a directory into a directory in python's path so python had only
> trunks
> python code and I got a "cannot import gnucash_core_c", then I copied
> ParIT's python files into the same directory, overwriting whatever trunk
> files had the same name and got "cannot import Job", finally, I rewrote
> trunk's python code into the directory, overwriting some files. in this
> final step, most of the files were still ParIT's, with a small set of them
> being from trunk. I got "cannot import name gncInvoiceLookup" which is
> supposedly in gnucash_core_c. seems like progress but also seems to not be
> going anywhere.
>
> If #3 is possible I'll need some direction.)
>
> wow, you read all this? thanks.
Hi ...
I've just compiled an untainted SVN and ... :
cd src/optional/python-bindings/example_scripts
export PYTHONPATH=$PYTHONPATH:/usr/local/lib/python2.6/site-packages
gnucash-env python simple_business_create.py sqlite3:///$HOME/test.gnucash
Opening the test.gnucash file shows the correct entries. No use of the ParitIT
stuff at all as some of the stuff on their site is a little out of date. The
latest scripts should be in SVN r19582.
Any idea why your modules are in /usr/lib/python2.5/site-packages/gnucash/ ?
I found that using ipython and running scripts line-by-line (copy / paste
style ) useful for debugging.
I'm using Fedora12 by the way so not terribly familiar with Ubuntu.
http://ipython.scipy.org/moin/
Ah, I just read your mail again! You're using gnucash 2.2.9? The latest
unstable release is 2.3.15, which is what I have. Do think it's worth trying
to get the old versions working when a new GnuCash release is imminent? There
are new functions available in the new version that you may find useful.
Mike E
--
GPG Key: 1024D/050895C2
Keyserver: http://pgp.mit.edu/
Search String: 0x050895C2
More information about the gnucash-devel
mailing list