How to test Python scripts with Moneydance

Diego Villamil's Avatar

Diego Villamil

15 Sep, 2020 02:54 AM

Hello, I would like to get better at developing my own Moneydance (can I just call you MD?) extensions in Python.
My developing background isn't very strong, since I come from a data analytics environment.
In any case, I have a couple of questions to ask about in order to get me started.

Basically I am used to running my projects with a localized Python, which is usually Python3. But I noticed that when I run scripts in MD it is calling 2.7.1. I also have Python 2.7 in my machine but it appears to be a different one than MD's, that is 2.7.17. My first question is if MD has their own localized version of Python, and if I can install other packages to use with.

Alternatively, if I'd like to test my script in development, I wouldn't how to connect to MD's model from outside of the MoneyBot Console.
Specifically, I've seen that the sample's scripts provided all have moneydance's module imported by default and call it as such.
My last question, is it possible to load a moneydance object from outside of the MoneyBot Console?

Thank you fro your help.

  1. 1 Posted by Stuart Beesley ... on 24 Sep, 2020 05:20 PM

    Stuart Beesley - JUST A FELLOW USER's Avatar

    Hi, I am a user and quite new to Python. As I understand it:
    - Moneydance MoneyBot uses Jython 2.7 - i.e. Java base - and is the latest available for now
    - No - you have to run these scripts within the MD environment/console.
    - I believe you can run a Java IDE to run Java (from within MD), but others will have to explain that.

  2. 2 Posted by dvillamil+infin... on 24 Sep, 2020 06:29 PM

    dvillamil+infinitekind's Avatar

    That does sound like a path to explore. I'll check out Jython.


  3. 3 Posted by davidcullen on 17 Oct, 2020 01:30 AM

    davidcullen's Avatar

    Hi Diego,

    It seems weened to run under the MoneyBot Console only, as explained in my earlier post: jython access to md outside MoneyBot Console.

  4. 4 Posted by Stuart Beesley ... on 17 Oct, 2020 08:38 AM

    Stuart Beesley - JUST A FELLOW USER's Avatar

    Further followup..

    I see no practical way to test Python scripts ‘outside’ Moneydance…. I.e. how would they work as they rely on MD?

    Further the moneydance (and _ui and _data) variables are created by the Moneydance>MoneyBot>Python console, so again, these can only exist when MD is running the scripts.

    I can see conceptually that a Python script could open the MD data file itself, and then go from there calling the APIs, but (understandably) I don’t see an API method to actually open the MD data file… So no dice there..

    FYI - whilst you need nothing other than a text editor to create MD Python scripts, I do now have IntelliJ IDE(A) configured to properly ‘manage’ Python(Jython) MD scripts - as follows:

    (IntelliJ seems more capable than PyCharm, but is from the same company)

    Rough steps

    Download/install IntelliJ (IJ)
    - add the Python addin (which is actually based on PyCharm)
    - add the Python 2.7 SDK into Platform settings
    - add(download) Adopt OpenJDK 14 (Hotspot) into IJ (this is what MD is built on)
    - open the MoneyDance application file / package contents and copy the contents somewhere for your project dev work
    - create a new project >> base it on Python 2.7
    - add a library (Java) and select all the .jar files within the application files you just copied from Contents/Java.
    - create/add a module called MoneyDanceApp
    >> select Java
    >>base it on OpenAdoptJDK 14
    >>in dependancies
    >>>>add/link to the library above you just created (as runtime)
    >>>>make sure adopt open JDK is listed
    >>>> add/link the contents directory from the MD contents you saved above and select classes and sources
    >>>> make sure the dependancy list is the MD Library, adoptJDK, module source, contents...

    - create another module called scripts
    >> based on Python 2.7
    >> in dependancies, add/link the MoneyDanceApp module you created above

    Now your code should recognise MD and resolve most references (not all).
    - It won’t resolve moneydance (and _ui and _data)
    - It won’t resolve the odd item within MD
    - It won’t resolve the odd Java item

    NOTE: We are using here the AdoptOpenJDK 14 which is what MD is built upon, but not the actual Java JRE that’s bundled with MD (I’ve found no way to do that, but not sure it matters too much).

    BUT on the whole it will help you manage your script better and look for errors.

    In addition, you can now create a debug/run configuration to run Moneydance within your IDE (it’s neat, but of no real use at the moment)
    >> Click add, application
    >> Main Class, type Moneydance (if you’ve done it right then this will resolve)
    >> Prog Args -d
    >> Working Dir = your MD data directory
    >> Use ClassPath of = MoneyDanceApp (that you created above)
    >> tick include dependancies with provided scope
    >> JRE = adopt-openJDK 14

    Then you can click RUN and MD will load. NOTE - make sure all other instances of MD are closed, also that it will not load your settings (due to sandboxing).. But all you need to do is copy config.dict
    From: /Users/xxx/Library/Containers/com.infinitekind.MoneydanceOSX/Data/Library/Application Support/Moneydance
    To /Users/xx/Library/Application Support/Moneydance
    Or wherever your system is storing its settings

    I’m now trying to workout how to go further, but that’s all for now…

    It has been suggested that: “you could write a java wrapper that launches moneydance... calling the method. Then when that main method returns you could access the Main.mainObj static variable and get the python interpreter using Main.mainObj.getPythonInterpreter()” but I haven’t worked out how to do that yet, or what that would give me….

    If anyone improves the above setup, or go further, do shout..?

    It’s quite funny that you can create scripts with a plain text editor, or do all the above and get the same result…!!!

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:


Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac