Search code examples
pythondebuggingscript-debuggingableton-live

Debugging Python within Ableton Live


How can I see script errors for my python MIDI Remote Scripts in Ableton Live? I've seen references online to a hidden Python console, but no documentation on how to open it, if it would even help me!

Currently I type code, reload the script, and see what happens. If nothing happens, then something is wrong. Very tedious...

Edit: I should also point out that there isn't anything useful in the Log.txt file either, yet that file is being updated.


Solution

  • To debug the control surface, you can define your own log method like so:

    def log(self, message):
        sys.stderr.write("LOG: " + message.encode("utf-8"))
    

    Usage example:

    year = 1999
    self.log("I'm gonna party like it's " + str(year))
    

    This will append

    21179419 ms. RemoteScriptError: LOG: Tonight I'm gonna party like it's 1999
    

    to your Log.txt.

    Also, it may be worth knowing that (at least as of Live 9.1) edited control surface files are recompiled every time you load a new song, no need to restart the application.

    EDIT: changed the stderr write method so that it doesn't write two lines and an extra return for every log