[GNC] MacOS Mojave Python Bindings - No module named gnucash

Aaron Surrain aaron at goodlookingsoftware.com
Mon Oct 22 22:06:24 EDT 2018


Thanks, John.

In case this will help anyone in the future:

I was still mostly at sea after your email but when I found the Portfile 
deep in the Macports area, I scanned it with your advice in mind and 
found that…

sudo port install gnucash

…is set to build with -DWITH_PYTHON=ON which was your second clue to 
me. Emboldened, I returned to experimenting around your first clue and 
improvised on the now ineffectual direction to run…

export PYTHONPATH=$PYTHONPATH:/opt/local/lib/python2.7/site-packages

…from…

https://wiki.gnucash.org/wiki/Python_Bindings

…after installing. I was relieved to find that gnucash was in that 
folder's cousin, and that running…

export PYTHONPATH=$PYTHONPATH:/opt/local/lib/python3.6/site-packages

…makes the bindings available at least to Macport's install of its own 
python. Running my script roughly like this…

/opt/local/bin/python3.6 script-to-run script-flags-and-parameters

…got me past my error and right into adjusting Jonathan's script to 
work for Python 3. One other note is that the documentation instructs 
one to run…

sudo port install gnucash +python27

…but that variant doesn't seem to be supported anymore judging by its 
absence here…

$ port variants gnucash
gnucash has the variants:
    debug: Enable debug binaries

…so, as I mentioned before, it seems to suffice to run…

sudo port install gnucash

Thanks again,
Aaron


On 21 Oct 2018, at 22:46, John Ralls wrote:

>> On Oct 21, 2018, at 5:15 PM, Aaron Surrain 
>> <aaron at goodlookingsoftware.com> wrote:
>>
>> I'm just getting started, running macOS Mojave, and trying to import 
>> from QuickBooks. I tried installing GNU Cash with Python Bindings per 
>> these instructions…
>>
>> https://wiki.gnucash.org/wiki/MacOSX/MacPortsDetail
>>
>> …and running the scripts from Jonathan Corbet's article…
>>
>> https://lwn.net/Articles/729087/
>>
>> …but I'm getting the error…
>>
>> ImportError: No module named gnucash
>>
>> …whenever I run Jonathan's script. I tried running it from the 
>> directory where I cloned it from github like this…
>> $ python ./qb_iif_to_gc -c -r ~/Downloads/exportQuickBooks.IIF
>> $ python2 ./qb_iif_to_gc -c -r ~/Downloads/exportQuickBooks.IIF
>> $ python3 ./qb_iif_to_gc -c -r ~/Downloads/exportQuickBooks.IIF
>>
>> …and a few variations without -c and -r.
>>
>> Some about my environment:
>>
>> $ which -a python
>> /usr/local/bin/python
>> /usr/bin/python
>>
>> $ which -a python2
>> /usr/local/bin/python2
>>
>> $ which -a python3
>> /usr/local/bin/python3
>>
>> $ echo $PYTHONPATH
>> :/opt/local/lib/python2.7/site-packages
>>
>> $ ls /opt/local/lib/python2.7/site-packages/
>> xcbgen
>
> GnuCash 2.6 is Python2, GnuCash 3 is Python3. You need to build 
> GnuCash with python bindings (-DWITH_PYTHON=YES on make, don’t 
> remember what it was for configure but configure --help will tell 
> you).
>
> If you need help getting the right packages installed and GnuCash 
> built with the right arguments you’ll have to ask on the MacPorts 
> support channels.
>
> Regards,
> John Ralls


More information about the gnucash-user mailing list