Sending OSC messages to SC with python

I am trying to send a simple test message to my SC session via a python script. I’m running SC and the python session on my raspberry pi.

I can see the messages when I use OSCfunc.trace(true), but when I just try to listen for the specific messages, nothing comes through. Every time I run the script, the trace message in SC has a different port in the address section. The recvPort is always the same.

I’ve tried this in SC as well as using the IP address of the raspberry pi:

n ="", 57120);
o = OSCFunc({arg msg, time, addr, recvPort; [msg, time, addr, recvPort].postln; }, '\hello', n);

This is the script I’m using in python with the pythonosc library:

from pythonosc import udp_client
from pythonosc import osc_message_builder

client = udp_client.SimpleUDPClient("", 57120)
msg = osc_message_builder.OscMessageBuilder(address = '/hello')
msg.add_arg(100, arg_type='i')
msg =

I tried setting both IP addresses to and also setting both to the raspberry pi’s IP address. I also tried setting the python script to and the SC address to the pi’s and vice versa.

You can see below that the message is being sent, but it won’t print via the OSCFunc that I created above.

OSC Message Received:
time: 3521.624961497
address: a NetAddr(, 57110)
recvPort: 57120
msg: [ /status.reply, 1, 0, 0, 2, 110, 0.76273965835571, 0.7864305973053, 44100.0, 44103.41838495 ]

OSC Message Received:
time: 3521.655185719
address: a NetAddr(, 60406)
recvPort: 57120
msg: [ /hello, 100 ]

Any pointers would be greatly appreciated!

Not sure if this is the only problem, but this looks like a typical port confusion.

n here is the address and port you’re sending from – but you’ve put in the SC port that you’re sending to. That won’t work for sure.

I’m not sure if it’s a documentation flaw – everybody (I mean everybody) makes this mistake at least once.

Try omitting n altogether (or omitting the port number from n).


That was exactly the problem! Thank you for clarifying…this now makes so much more sense. Cheers!