# Communication between python3 and sonic pi using osc

**URL:** <https://in-thread.sonic-pi.net/t/communication-between-python3-and-sonic-pi-using-osc/3357>\
**Category:** Support, Help & Resources\
**Created:** [February 27, 2020, 8:01pm UTC](https://in-thread.sonic-pi.net/t/communication-between-python3-and-sonic-pi-using-osc/3357 "2020-02-27T20:01:32Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![nlb](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/nlb/32/997_2.png) [@nlb](https://in-thread.sonic-pi.net/u/nlb)\
**Post date:** [February 27, 2020, 9:05pm UTC](https://in-thread.sonic-pi.net/t/communication-between-python3-and-sonic-pi-using-osc/3357/3 "2020-02-27T21:05:16Z")

</div>

> [@Link sonic pi to Python](http://in-thread.sonic-pi.net/t/link-sonic-pi-to-python/2938/5):
>
> @Gydhia Here is a simple example with a Python client sending OSC messages to Sonic Pi. First, the Python client: import random import time from pythonosc import udp\_client client = udp\_client.SimpleUDPClient('127.0.0.1', 4559) while True: client.send\_message("/bpm", random.randint(40, 200)) time.sleep(5) The Python code establishes a client connection to the Sonic Pi OSC server which runs on port 4559 on my localhost (127.0.0.1). OSC is a network protocol, so it doesn’t matter w…

---

_[View the full topic](https://in-thread.sonic-pi.net/t/communication-between-python3-and-sonic-pi-using-osc/3357)._
