how to import modules int custom python coded nodes

xtensor's Avatar


06 Jan, 2023 01:07 PM

I'm writing a custom python coded node that would need to import pygame ( This would enable me to output midi notes to a synth. Is this at all possible?

Thanks for any help in advance.

  1. Support Staff 1 Posted by john on 06 Jan, 2023 10:51 PM

    john's Avatar


    Sorry, but I'm out of my depth on this one.

    In theory, I think you should be able to access python libraries using custom nodes. But there may be some issues. I found this exchange in the forum:

    "NodeBox uses Jython, a version of Python 2.7 that runs on the JVM. So it doesn't look in the sys.path of Python 2 or 3."

    You could try installing pygame on your machine and invoke it your .py file (import pygame). But if Nodebox doesn't see it, you'll get a "No module name pygame" error.

    I also see that pygame is based on Python 3.6 and has some other dependencies as well. This may cause further issues.

    If you do get it working on your system, be aware that it would not work for anyone else unless they also install pygame and do whatever additional voodoo required.

    Could you use OSC instead of midi to output to your synth? That's probably a stupid question, but if somehow you could, you might try the send OSC node.

    Wish I could be of more help. Adding Frederik to the list on the off chance he will have time to weigh in.


  2. 2 Posted by xtensor on 07 Jan, 2023 11:18 AM

    xtensor's Avatar

    Hi John

    Thank you very much for your reply. It's clarified things for me and was

    I've been working on making so called 'parquet deformations' and nodebox 3
    has made it possible, but without your invaluable Cartan Node Library I
    couldn't have done it. So thank you for making them available to us.

    I've included a couple of examples. I really wanted, out of interest, to
    see if I could use some of the parameters to trigger some sound on my Mac
    using an internal synth. This was just an idea on top, I've really
    completed what I set out to do.

    Many thanks again, I'll look into jython and OSC just for fun anyway.

    Best wishes

  3. Support Staff 3 Posted by john on 08 Jan, 2023 10:57 PM

    john's Avatar


    Thanks for those kind words. Much appreciated.

    I am also quite impressed by your parquet deformations - very Escher-like. It might be interesting to capture each enclosed area as a separate shape and play with coloring them.

    I look forward to seeing more of your work!


  4. 4 Posted by xtensor on 09 Jan, 2023 11:45 AM

    xtensor's Avatar

    Thanks John

    I'll post more work on the 'show your work' thread. And thank you for the
    Cartan 3.1 Library you've just made available.

    Best wishes

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

Recent Discussions

16 May, 2024 02:11 AM
16 May, 2024 01:58 AM
14 May, 2024 01:29 AM
13 May, 2024 12:36 AM
12 May, 2024 07:46 PM


05 May, 2024 04:38 PM
03 May, 2024 06:50 AM
03 May, 2024 12:30 AM
03 May, 2024 12:09 AM
19 Apr, 2024 04:41 AM
16 Apr, 2024 06:18 PM