python/demo.py

311 views
Skip to first unread message

Jeroen De Vlieger

unread,
Jan 21, 2013, 5:09:32 AM1/21/13
to ledge...@googlegroups.com
how can I run the python/demo.py?

$ pwd
~/CodingProjects/ledger_acprep_build/python
$ python demo.py
Traceback (most recent call last):
  File "demo.py", line 10, in <module>
    import ledger
ImportError: No module named ledger

with kind regards,

Jeroen

Zack Williams

unread,
Jan 21, 2013, 10:25:19 AM1/21/13
to ledge...@googlegroups.com
On Mon, Jan 21, 2013 at 3:09 AM, Jeroen De Vlieger <fly...@gmail.com> wrote:
> how can I run the python/demo.py?
>
> $ pwd
> ~/CodingProjects/ledger_acprep_build/python
> $ python demo.py
> Traceback (most recent call last):
> File "demo.py", line 10, in <module>
> import ledger
> ImportError: No module named ledger

My understanding is that Python scripts need to be run through ledger,
using the "python" verb:

--
$ ledger python demo.py
Welcome to the Ledger.Python demo!
Demo completed successfully.
--

Also, you need to build ledger (and boost) with python support for
this to function.

- Zack

Alexis

unread,
Jan 21, 2013, 10:40:55 AM1/21/13
to ledge...@googlegroups.com
Hi Jeroen,
with a python enabled ledger built
try the following from the ledger source directory:
$ ledger python python/demo.py


Best regards,
Alexis

John Wiegley

unread,
Jan 21, 2013, 4:22:52 PM1/21/13
to ledge...@googlegroups.com
>>>>> Zack Williams <zdw...@gmail.com> writes:

> On Mon, Jan 21, 2013 at 3:09 AM, Jeroen De Vlieger <fly...@gmail.com> wrote:
>> how can I run the python/demo.py?
>>
>> $ pwd
>> ~/CodingProjects/ledger_acprep_build/python
>> $ python demo.py
>> Traceback (most recent call last):
>> File "demo.py", line 10, in <module>
>> import ledger
>> ImportError: No module named ledger

Importing ledger like this only works after you've done a 'make install'. I
created the 'python' verb simply for running the Python demo scripts directly
out of a build tree. You could also edit your PYTHONPATH and it would work
with normal importing that way too.

What I mean to say is that the python verb is merely a developer's
convenience, it is not required for the Python bridge to work.

John

Jeroen De Vlieger

unread,
Jan 22, 2013, 6:35:04 AM1/22/13
to ledge...@googlegroups.com
On Mon, Jan 21, 2013 at 10:22 PM, John Wiegley <jo...@newartisans.com> wrote:
>>>>> Zack Williams <zdw...@gmail.com> writes:

> On Mon, Jan 21, 2013 at 3:09 AM, Jeroen De Vlieger <fly...@gmail.com> wrote:
>> how can I run the python/demo.py?
>>
>> $ pwd
>> ~/CodingProjects/ledger_acprep_build/python
>> $ python demo.py
>> Traceback (most recent call last):
>> File "demo.py", line 10, in <module>
>> import ledger
>> ImportError: No module named ledger

Importing ledger like this only works after you've done a 'make install'.  I
created the 'python' verb simply for running the Python demo scripts directly
out of a build tree.  You could also edit your PYTHONPATH and it would work
with normal importing that way too.
And what would need to be included in the pythonpath to make 'import ledger'  work?
Where does the ledger python module live?

Christopher Allan Webber

unread,
Feb 4, 2013, 8:13:36 PM2/4/13
to ledge...@googlegroups.com
Jeroen De Vlieger writes:

> On Mon, Jan 21, 2013 at 10:22 PM, John Wiegley <jo...@newartisans.com>wrote:
>
>> >>>>> Zack Williams <zdw...@gmail.com> writes:
>>
>> > On Mon, Jan 21, 2013 at 3:09 AM, Jeroen De Vlieger <fly...@gmail.com>
>> wrote:
>> >> how can I run the python/demo.py?
>> >>
>> >> $ pwd
>> >> ~/CodingProjects/ledger_acprep_build/python
>> >> $ python demo.py
>> >> Traceback (most recent call last):
>> >> File "demo.py", line 10, in <module>
>> >> import ledger
>> >> ImportError: No module named ledger
>>
>> Importing ledger like this only works after you've done a 'make install'.
>> I
>> created the 'python' verb simply for running the Python demo scripts
>> directly
>> out of a build tree. You could also edit your PYTHONPATH and it would work
>> with normal importing that way too.
>>
> And what would need to be included in the pythonpath to make 'import
> ledger' work?
> Where does the ledger python module live?

I'm also wondering this. It doesn't look like there's any nice ledger
directory that can be added to the pythonpath. I'd expect something
like:

./python-lib/ledger/__init__.py

the "ledger python" verb is also not working here, so not sure how to do
this without doing a make install (which would make keeping up with git
development a bit harder maybe?)

Christopher Allan Webber

unread,
Feb 5, 2013, 9:34:33 AM2/5/13
to Christopher Allan Webber, ledge...@googlegroups.com
FWIW, was pointed out that I wasn't compiling python support in ledger,
apparently :)
Reply all
Reply to author
Forward
0 new messages