jaseg / python-mpv

Python interface to the awesome mpv media player
https://git.jaseg.de/python-mpv.git
Other
531 stars 67 forks source link

"Cannot Find libmpv in the usual places"(OSX) #256

Closed gavspav closed 1 year ago

gavspav commented 1 year ago

I've seen other people with this issue but none of the solutions are working for me. I have an M1 Mac, I've installed MPV via homebrew and it works as a player. But 'import mpv' is throwing an error in my script.

I've even tried adding the path with the libmpv file to _dyld.py buy it doesn't seem to find it. I'm not sure what the next step is!

gavspav commented 1 year ago

What did work for me is installing mpv using homebrew and then hardcoding the location of the libmpv file into the mpv.py file.

In my case this was: sofile = "/opt/homebrew/lib/libmpv.2.dylib"

I guess the better way to do it would've been to set my path variables somehow but I just couldn't figure it out!

jaseg commented 1 year ago

I don't have a MacOS to try this out, but a google search suggests the DYLD_LIBRARY_PATH or the DYLD_FALLBACK_LIBRARY_PATH environment variable might be the right place to put the /opt/homebrew/lib path. From https://github.com/orgs/Homebrew/discussions/3424 it sounds like that is a known issue on homebrew on MacOS on ARM. From that discussion it also sounds like using a python installed through homebrew might fix this, since they build it with a patch for this behavior.

I'm closing this as an upstream issue, since there is not much we would do on our end to fix it -- I don't want to second guess python's find_library here, and that is really the place where this should be fixed.

In the meantime, I always intended mpv.py to be a single file you can just copy into your project and modify as needed. It's not considered good python packaging practice, but I think it's really not that bad, especially considering that python-mpv is very stable by now, and not security-sensitive.