sookie
sookie

Reputation: 2517

Python - Pymediainfo Module [Error 126] The specified module could not be found

The error I'm receiving is this:

Traceback (most recent call last):
File "C:\Users\Me\test3.py", line 4, in <module>
   media_info = MediaInfo.parse("video.mp4")
File "C:\Python27\lib\site-packages\pymediainfo-2.0-py2.7.egg\pymediainfo\__init__.py", line 70, in parse
   lib = windll.MediaInfo 
File "C:\Python27\lib\ctypes\__init__.py", line 435, in __getattr__
   dll = self._dlltype(name)
File "C:\Python27\lib\ctypes\__init__.py", line 365, in __init__
   self._handle = _dlopen(self._name, mode)
WindowsError: [Error 126] The specified module could not be found

Pymediainfo has been the only module to have caused this error for me. To see if the problem was related to pip, I reinstalled it through the zip file found here to no avail. Here is the code causing the error:

from pymediainfo import MediaInfo

# sample code from pymediainfo docs
media_info = MediaInfo.parse("video.mp4")
for track in media_info.tracks:
    if track.track_type == 'Video':
        print track.bit_rate, track.bit_rate_mode, track.codec

If you need any more info, let me know.

Upvotes: 1

Views: 2991

Answers (3)

Gachara Thomi
Gachara Thomi

Reputation: 51

Works for me when you copy the MediaInfo.dll file from here: https://mediaarea.net/en/MediaInfo/Download/Windows into the same folder as your script.

Upvotes: 1

Vaas
Vaas

Reputation: 67

I got the same error and this is what I did to resolve it:

The thing is, pymediainfo is a wrapper of mediainfo. So it needs MediaInfo.ddl in the env path.

You can get MeidaInfo.ddl from here: https://mediaarea.net/en/MediaInfo/Download/Windows

Download the dll for your platform and place it on your env path. That's it.

Upvotes: 0

marksman
marksman

Reputation: 11

I guess you forgot to add the dll path for Mediainfo.dll.

import os

os.environ['PATH'] = os.path.dirname('file/path/to/Mediainfo.dll') + ';' + os.environ['PATH']

Upvotes: 1

Related Questions