# Mac Python support in OBS 26?



## claudeheintz (Sep 29, 2020)

Does OBS Studio 26 remove python support on the Mac?  I downloaded it and my python script disappears.  I switched back to 25.0.8 and my script works...

(The script works just fine using OBS Studio 26 on Windows.)


----------



## claudeheintz (Sep 30, 2020)

Maybe I should clarify, the "scripts" window does not have a "Python Settings" tab like 25.0.8.  I looked at previous release candidate versions 26r1, 26r3, and neither of them has the python settings tab in scripts.

When I try to add my python script, it is not allowed to be selected.

All of the above does not apply to version 26 on Windows.  There the script continues to work as before.

So, for the Mac version, is this a bug?  An intentional omission?  Other than posting here, where would I find this information as searching these forums and the documentation wiki don't turn up anything?


----------



## Tangential (Oct 1, 2020)

Interesting. I didn't know Python was supported at all on Mac


----------



## DeckerEgo (Oct 3, 2020)

Yup, Python worked just fine in MacOS in 25. Any ideas on how it should work in 26?


----------



## DeckerEgo (Oct 3, 2020)

Welp... it appears to have been disabled entirely in 26 - see https://github.com/obsproject/obs-studio/pull/3172


> Python scripting support is not in a working state on macOS and with Homebrew updating default Python to v3.8.3 there will be build issues if an updated Python is installed and prioritised over macOS' system Python (as OBS doesn't build successfully with newer Python versions present). Disabling Python scripting support for macOS builds for the time being avoids this issue.


Not sure how this is considered to be a "non-breaking change" since now scripts that ran in 25 will not work in 26.

I couldn't find an issue or open PR for resuming MacOS Python support, so it appears to be gone for the foreseeable future.


----------



## aega (Oct 3, 2020)

Looks like we're stuck on 25.0.8 then, as there's no way I'm upgrading to 26 without Python support (too many scripts that wouldn't work if I converted to Lua). I thought brew made it easy to switch between different Python versions.


----------



## JamLion (Oct 3, 2020)

Well that SUCKS. Come on, OBS. I don't know why they would disable it... unless they're still working on it. In that case, we should wait for version 26.0.1 to come out, as that might have Python support. WEIRD.


----------



## claudeheintz (Oct 3, 2020)

To clarify the original post, Version 25.0.8 did not appear to work with Python 3.8.  To make it work, I had to install python 3.7 downloaded from the official Python website and put the path into OBS.

There is a minefield of managing python versions.  Apple's current advice to developers for Catalina is to include a local copy of the python framework with the application and link against that.  That way, you do not depend on the python installed on the user's computer.  And the user does not screw up other python dependancies on their computer by requiring a specific version to be installed.  The potential drawback to this approach is using pip to install modules for the application's private python.  Perhaps this will resolve if Apple finally upgrades the system default python from 2.7 on the next MacOS version.


----------



## claudeheintz (Oct 3, 2020)

Oops, I wasn't completely correct.  I just switched from python 3.7 to 3.8 and OBS 25.0.8 seems to work with both.


----------



## claudeheintz (Oct 3, 2020)

OK, so I wasn't completely correct in the last post either..  OBS 25.0.8 will work with the latest python 3.8.5.  But, ONLY if you go to /Library/Frameworks/Python.framework/Versions/3.8 and duplicate the alias "libpython3.8.dylib" and re-name it "libpython3.7m.dylib".

It looks from the log file like OBS 25.0.8 is looking for a hardcoded file or symlink named  "libpython3.7m.dylib" to pass to dlopen().

Python 3.7.9 on the mac includes two symlinks in the 3.7/lib folder, "libpython3.7m.dylib" and "libpython3.7.dylib".  Both point to the same place.  But OBS seems to require specifically the "libpython3.7m.dylib" one.


----------



## DeckerEgo (Oct 3, 2020)

It isn't too bad to manage multiple versions of Python on MacOS using pyenv. As an example, to install the appropriate version of Python with shared libraries for OBS, run:
`CONFIGURE_OPTS=--enable-shared pyenv install 3.7.8`


----------



## cognitiaclaeves (Jun 11, 2021)

I had a little trouble understanding how to apply what was said above. I was able to determine that python scripts are supported again in OSB 27 by reading up on this issue in the project in github. It turned out that brew had installed a later version of python than 3.7.8. I'm not really sure when I did this, or when something had a dependency for 'python', but this what I saw in the log: *Help > Log Files > View Current Log* :


```
18:33:30.258: os_dlopen(libpython3.9.dylib->libpython3.9.dylib): dlopen(libpython3.9.dylib, 257): image not found
18:33:30.258:
18:33:30.258: [Python] Could not load library: libpython3.9.dylib
18:33:30.259: os_dlopen(/Users/jnorment/.pyenv/versions/3.7.8/lib/libpython3.9.dylib->/Users/jnorment/.pyenv/versions/3.7.8/lib/libpython3.9.dylib): dlopen(/Users/jnorment/.pyenv/versions/3.7.8/lib/libpython3.9.dylib, 257): image not found
```

It's pretty clear, above that I'd pointed to the wrong version of python in *Tools > Scripts > Python Settings*. Here is what brew had to say about the python package:


```
brew info python
python@3.9: stable 3.9.5 (bottled)
Interpreted, interactive, object-oriented programming language
https://www.python.org/
/usr/local/Cellar/python@3.9/3.9.5 (3,162 files, 55.4MB) *
  Poured from bottle on 2021-05-25 at 07:11:37
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/python@3.9.rb
License: Python-2.0
==> Dependencies
Build: pkg-config ✔
Required: gdbm ✔, mpdecimal ✔, openssl@1.1 ✔, readline ✔, sqlite ✔, xz ✔
==> Caveats
Python has been installed as
  /usr/local/bin/python3

Unversioned symlinks `python`, `python-config`, `pip` etc. pointing to
`python3`, `python3-config`, `pip3` etc., respectively, have been installed into
  /usr/local/opt/python@3.9/libexec/bin

You can install Python packages with
  pip3 install <package>
They will install into the site-package directory
  /usr/local/lib/python3.9/site-packages
```

Here is how I fixed it:


```
CONFIGURE_OPTS=--enable-shared pyenv install 3.9.5
python-build: use openssl@1.1 from homebrew
python-build: use readline from homebrew
Downloading Python-3.9.5.tar.xz...
-> https://www.python.org/ftp/python/3.9.5/Python-3.9.5.tar.xz
Installing Python-3.9.5...
python-build: use readline from homebrew
python-build: use zlib from xcode sdk
Installed Python-3.9.5 to /Users/jnorment/.pyenv/versions/3.9.5
```

The last line contained the path that copied into the *Python Settings *path.

I'm being very thorough in this explanation because I anticipate a possibility that if brew updates python beyond 3.9.5, that it could break the python scripts in OBS. I don't know enough about when such an event might happen, so I'm leaving plenty of bread crumbs, just in case.


----------



## DeckerEgo (Jun 19, 2021)

Confirmed that Python support has returned to MacOS in OBS 27 - working once again for the Tally Pi scripts!


----------

