-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mac OS X update breaks pymediainfo #24
Comments
Are you using the git version or the 2.0 release?
|
If you use the git version, it should never attempt to load the |
Ok thanks. Yes, it was v2.0 that pip installed. |
Can you please try the git version? |
Still didn't work. Here is the error traceback:
|
Is it called something else on your system? |
There's this file:
|
That's weird, it means the official Python bindings have it wrong… |
There is a |
Ah ok. I was using, and have always just installed the CLI version because I use MediaInfo outside Python as well. Pymediainfo traditionally worked with the CLI, obviously. Maybe its worth mentioning the DyLib version in your install docs or something? (if you haven't already) |
Since I took over development (version 2.0), the command-line application is no longer used. The changelog mentions it but maybe not clearly enough. pymediainfo.MediaInfo(subprocess.check_output(["mediainfo", "--output=XML", "-f", "filename.ext"])) Using the library is just easier and more efficient. |
Ok, makes sense. I'm actually unsure where to put the DyLib file. Do you know? I tried putting in the directory from where I'm running Python... it seems pymediainfo finds the DyLib file, but results in Python crashing with a segmentation fault. (Python 2.7.8) |
I have little experience with Mac OS, did you manage to make it work? It probably goes to /lib or similar. |
Hi @mattbodman, did you manage to load the dylib properly? Can we close this issue? |
Sorry, haven't had a chance to try it. Close it if you like
|
I actually ran out of time to figure out where to put the dylib file, so I reverted to Linux. Sorry about that. |
I have this issue too, maybe useful if the issue could be reopened?
|
Hi! |
Hey! The file |
I'm no Mac expert but I think that simply overriding os.environ["LD_LIBRARY_PATH"] = os.environ.get("LD_LIBRARY_PATH", "") + ":/Applications/MediaInfo.app/Contents/Resource" |
Nope, sorry still doesn't work, the error is the same. I have solved my program without using pymediainfo though. |
What about os.environ["DYLD_LIBRARY_PATH"] = os.environ.get("DYLD_LIBRARY_PATH", "") + ":/Applications/MediaInfo.app/Contents/Resource" |
Nope sorry, still the same error Edit: This happens if I run it with python3 if I use python it says |
Are there any updates with this? |
@OmgImAlexis I don't really know, I can't reproduce it myself as I don't have a Mac to test all the time. |
Yes and also works if we use We also tried editing pymediainfo and adding this before the command to try CDLL. From the looks of it the ENV param needs to be set before Python starts, I wonder if you could get around that by starting it and then forking the process or does Python itself need restarting?
os_folder is the absolute path to our copy of |
Nice, thanks for testing! I'll borrow someone's Mac and perform more tests. Maybe ctypes has a parameter to add more paths from which to load its libraries. |
It doesn't work for me...any other idea? the error continues being: "OSError: dlopen(libmediainfo.dylib, 6): image not found" |
@fralomba where is your lib located? |
I have installed it with pip, and tried to follow @GiancarloFusiello 's hint but nothing changed. Same error. The lib is located in usr/local/lib. Do u know how to help me? |
@fralomba Here is what I did & works ... Download & Extract following
Create directory Modify (replace username) Install (replace username)
|
@fralomba Just to be sure: you're aware that pip does not install the mediainfo library, right? |
There should be no need to move dylib files around. With the latest version, you can simply pass the dylib path to |
Hi,
|
@joyearnaud I have just pushed a new branch with more verbose exceptions when the library cannot be loaded, can you try it with
And let me know what the exception looks like now? It should show something like this with the paths that were tested:
|
Thank for your prompt answer @sbraz Just to be precise, I'm using Apple Silicon architecture; My PATH% echo "$PATH"
/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/homebrew/bin Medialib files location% ls usr/local/lib
libmediainfo.0.dylib libmediainfo.dylib
% ls usr/local/bin
libmediainfo.0.dylib libmediainfo.dylib mediainfo Error looks like with new verbose branchTraceback (most recent call last):
File "/Users/xxx/Project/filesort/run.py", line 11, in <module>
sort_files(PATH, length = LENGTH)
File "/Users/xxx/Project/filesort/filesort/sort_files.py", line 36, in sort_files
sort_other(filepath, out_repo)
File "/Users/xxx/Project/filesort/filesort/sort_files.py", line 167, in sort_other
if is_video(filepath, out_repo):
File "/Users/xxx/Project/filesort/filesort/sort_files.py", line 157, in is_video
media_info = MediaInfo.parse(filepath)
File "/Users/xxx/Library/Python/3.8/lib/python/site-packages/pymediainfo/__init__.py", line 431, in parse
lib, handle, lib_version_str, lib_version = cls._get_library(library_file)
File "/Users/xxx/Library/Python/3.8/lib/python/site-packages/pymediainfo/__init__.py", line 329, in _get_library
raise OSError(
OSError: Failed to load library from libmediainfo.0.dylib, libmediainfo.dylib - dlopen(libmediainfo.0.dylib, 6): no suitable image found. Did find:
libmediainfo.0.dylib: no matching architecture in universal wrapper
/usr/local/lib/libmediainfo.0.dylib: no matching architecture in universal wrapper
/usr/local/lib/libmediainfo.0.dylib: no matching architecture in universal wrapper
/Users/xxx/Project/filesort/libmediainfo.0.dylib: no matching architecture in universal wrapper, dlopen(libmediainfo.dylib, 6): no suitable image found. Did find:
libmediainfo.dylib: no matching architecture in universal wrapper
/usr/local/lib/libmediainfo.dylib: no matching architecture in universal wrapper
/usr/local/lib/libmediainfo.0.dylib: no matching architecture in universal wrapper
/Users/xxx/Project/filesort/libmediainfo.0.dylib: no matching architecture in universal wrapper |
I'm no Mac OS expert but it looks like your library isn't compatible with the version you have, do the MediaInfo GUI or the CLI ( |
Seems to work xxx@MacBook bin % mediainfo /Users/xxx/Data
General
Complete name : /Users/xxx/Data/P1090707.MOV
Format : QuickTime
Format/Info : Original Apple specifications
File size : 11.4 MiB
xxx@MacBook bin % mediainfo --version
MediaInfo Command line,
MediaInfoLib - v21.03
|
I don't think Python 3.8 is supposed to support Apple Silicon (or OSX1 11), where did you get it? Can you try with this newer Python installer please? |
@sbraz I'm brand new Apple user and it's a brand new MacBook: Python 2.xx and Python 3.8 are preinstalled; Browsing about this version problem show me this article:
I will definitively try version 3.9 and let you know. |
@sbraz Thank for your time and advice, Python 3.9.4 works fine and resolves my problem |
You're welcome. Can you tell me if the pymediainfo wheel (which includes libmediainfo) works out-of-the box or if you had to put the Since the lib is built with v20.09, I doubt it'll work. In that case, I might create a new release that includes the newer libmediainfo. |
First I put everything. Now with this conf (without xxx@MacBook filesort % ls -R /usr/local
bin lib
/usr/local/bin:
2to3 easy_install-3.9 idle3.9 pip3 pydoc3 python3 python3.9
2to3-3.9 idle3 mediainfo pip3.9 pydoc3.9 python3-config python3.9-config
/usr/local/lib:
it's working too. |
Hmm so the older version did work with Apple Silicon then. Does
|
erratum : In my process to make it work I put With these xxx@MacBook filesort % python3 -c "from pymediainfo import MediaInfo; print(MediaInfo._get_library())"
(<CDLL 'libmediainfo.0.dylib', handle 7fb743ca8ad0 at 0x7fb7481361c0>, 140425093475744, '0.7.84', (0, 7, 84)) So, deleting them made running your command fail with xxx@MacBook filesort % python3 -c "from pymediainfo import MediaInfo; print(MediaInfo._get_library())"
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/Users/xxx/Library/Python/3.9/lib/python/site-packages/pymediainfo/__init__.py", line 329, in _get_library
raise OSError(
OSError: Failed to load library from libmediainfo.0.dylib, libmediainfo.dylib - dlopen(libmediainfo.0.dylib, 6): image not found, dlopen(libmediainfo.dylib, 6): image not found |
Can we maybe chat on https://gitter.im/ to avoid flooding this issue? I'd like to make it easier for future pymediainfo users to run it on OSX, and from what I see:
EDIT: the issue was that @joyearnaud was still running the I have released v5.1.0 which will include the latest library as well as the improved exception messages. |
for anyone else having this issue. I encountered it on 12.5.1 on M1/arm mac. The only thing that worked for me was downloading the arm64 libmediainfo.0.dylib, libmediainfo.dylib from here https://mediaarea.net/en/MediaInfo/Download/Mac_OS and sticking them into the project |
Hi @swannie-eire so the bundled MediaInfo v21.03 does not work but newer versions do? Can you please try older versions and let me know which version fixed the problem. I'll probably make a new pymediainfo release once I know that this actually fixes the problem. |
MediaInfo v21.03 version is with 2 "flavors", one with "old" i386+x86_64 and one with M1 compatible x86_64+arm64, maybe you used i386+x86_64? |
Hi @JeromeMartinez thanks for the feedback, I'll check that. This means I should create two binary packages? One for M1 Macs and one for older CPUs? |
No. One for i386 and one for newer CPUs is a lot better, as i386 is maybe for 0.1% (or less!) of your users, it would be less problematic to have an unique build for 99.9% rather that a split between ARM and Intel CPU (still lot of x86_64 users). Or maybe just avoid an i386 version, last macOS with i386 support is 10.6 (11 year old), as we did (v21.09+ are without i386 support, we switched from i386+x86_64 to x86_64+arm64 because in 2021 nearly no one uses new versions of MediaInfo on 10+ year old machines). but I am surprised that you had no complain about M1/arm compatibility sooner, such machine is very common nowadays, maybe users use pymediainfo with another version of MediaInfo library than yours? |
Instead of including the old i386+x86_64 dylib in wheels, we'll now use the x86_64+arm64 version, following upstream's decision. More info here: #24 (comment)
Thanks for the explanation @JeromeMartinez, I have to admit I kinda forgot that the new CPUs were using a different architecture. I have just released pymediainfo 6.0.0 and I built the wheel using the arm64-compatible libmediainfo → https://files.pythonhosted.org/packages/75/1a/2f018bfe7678fa48e1f4d30b2bba77913bd5145966b405b383e2716093e1/pymediainfo-6.0.0-py3-none-macosx_12_0_x86_64.whl EDIT: I ended up using an older macOS version for v6.0.1 (10.15) otherwise pip didn't attempt to install the wheel for pre-12.0 macOS versions. |
Could have been the update to OS X 10.11.4 or an update of Command Line Tools (sorry I'm not sure which caused it). However, using CDLL no longer works.. This error results: OSError: dlopen libmediainfo.so.0, 6 cannot be found, so I guess Apple moved something. This exact happened after the upgrades on two separate Apple machines and the fix below worked for both.
To fix, I rolled back pymediainfo to v 1.4
The text was updated successfully, but these errors were encountered: