How-to Setup and Use Python with OBS on a Mac
Tags: obs, python, media
Published: 2023-10-20 22:24:06

[Open Broadcaster Software (OBS)](https://obsproject.com/) can be a helpful tool and tailored for different use cases with custom scripts. These can help solve a wide variety of dynamic features such as counters, timers, displaying data fetched by API, scene transitions, audio/video filters, etc. that require custom automation when hosting live streams.

A lot of the information out there about scripting in OBS is not un-surprisingly YouTube videos for Windows users. This is the blog post I wish I had found when I started setting up [OBS 30](https://dev.to/dolbyio/top-reasons-for-updating-to-the-new-obs-300-release-g6m) as a development environment for macOS.

> **tl;dr**: Use ⌘+shift+G and type in the path to `/opt/homebrew/Cellar/python@x.y/x.y.z/Frameworks`

## Configuring Python for OBS on a Mac

On the surface this sounds like it should be simple, but there are a few gotchas that I had to research and took a non-trivial amount of time to find the right answer.

The [Python/Lua Scripting](https://docs.obsproject.com/scripting) docs say:
> NOTE: To use Python on Windows or macOS, you must download and install a Python version that matches your OBS architecture. Then, in the scripting dialog, you must set the path to the Python install in the “Python Settings” tab.

There are a few additional details that may be helpful.

## Step 1: How-to Find Your Installed Python Location

This can vary from system to system depending on how you've installed Python. In my case, I'm running Python 3.11 that was installed with Homebrew.

```bash
> which python3
/opt/homebrew/bin/python3

>
```

This is not the path that OBS wants however, the path you need is something that might look like this:

```bash
/opt/homebrew/Cellar/python@3.11/3.11.4_1/Frameworks
```

If you input a path to the `/bin` directory or even the root `python@3.11` or go to far into the `python@3.11/Frameworks/Python.framework` folder you'll be left with `Python not currently loaded`.


![Python not currently loaded](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ai449uef8nnmvsv4ildj.png)


## Step 2: How-to Input the Python Path Settings

To configure OBS, you'll need to select the menu **Tools -> Scripts** and then click on the _Python Settings_ tab:

![Select Tools](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mvb69bgiplmwmggstaf0.png)

To input the Python location may depend on how you've configured your system, but typically the `/opt` folder is not something you will see in your Finder that OBS brings up for selecting the _Python Install Path_. 

The trick here is a keyboard shortcut. Use ⌘+shift+G to  pop-open an input window to type in the path.

When you see the message **Loaded Python Version** along with the version you are ready to roll.

![Python Settings for OBS on a Mac](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nbmpom9xyr12tkpe8aam.png)

## Ready to Script

You are now prepared to run Python scripts you may find written by others or start developing your own. 

Here are some you may find as helpful examples in the OBS Forums:
https://obsproject.com/forum/resources/categories/scripts.5/?prefix_id=6&order=rating_weighted&direction=desc

Here are the docs for more on how to write scripts:
- https://docs.obsproject.com/scripting
- https://obsproject.com/wiki/Getting-Started-With-OBS-Scripting

More examples of this in this series later.