Skip to content

Cannot find mpv-1.dll #104

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

Closed
Nearata opened this issue Feb 7, 2020 · 5 comments
Closed

Cannot find mpv-1.dll #104

Nearata opened this issue Feb 7, 2020 · 5 comments

Comments

@Nearata
Copy link

Nearata commented Feb 7, 2020

Operating System: Windows 10 Home (1909)
Python Version: 3.8
MPV Version: 0.45

Description

Cannot find mpv-1.dll but the file is in the same directory of the script.

Folder structure

- vvvvid_downloader
-- mpv.py
-- mpv-1.dll
-- test_mpv.py

Code

# test_mpv.py

url = "https://example.com/vod.m3u8"
player = MPV(osc=True)
player.play(url)
player.wait_for_playback()
player.terminate()

Traceback

Traceback (most recent call last):
  File "test_mpv.py", line 2, in <module>
    from mpv import MPV
  File "E:\GitHub Workspace\vvvvid-downloader\vvvvid_downloader\mpv.py", line 33, in <module>
    raise OSError('Cannot find mpv-1.dll in your system %PATH%. One way to deal with this is to ship mpv-1.dll '
OSError: Cannot find mpv-1.dll in your system %PATH%. One way to deal with this is to ship mpv-1.dll with your script and put the directory your script is in into %PATH% before "import mpv": os.environ["PATH"] = os.path.dirname(__file__) + os.pathsep + os.environ["PATH"] If mpv-1.dll is located elsewhere, you can add that path to os.environ["PATH"].
@McSinyx
Copy link
Contributor

McSinyx commented Feb 7, 2020

Have you tried doing what is suggested by the error?

@Nearata
Copy link
Author

Nearata commented Feb 7, 2020

@McSinyx Yes and works, but it worked before the lastest update.

However, i fixed like this:

# mpv.py

os.add_dll_directory(os.getcwd())
if os.name == 'nt':
    # dll = ctypes.util.find_library('mpv-1.dll')
    dll = CDLL("mpv-1.dll")
    ...
    # backend = CDLL(dll)
    backend = dll
    fs_enc = 'utf-8'

@McSinyx
Copy link
Contributor

McSinyx commented Feb 8, 2020

it worked before the lastest update

That was not very secured so it was fixed sometime ago. See #96 for discussion.

@newresu
Copy link

newresu commented Aug 11, 2024

for some reason mine was not downloaded from the mpv installation with scoop (new to windows here.)

I basically downloaded it from https://sourceforge.net/projects/mpv-player-windows/files/libmpv/

extracted the libmpv.dll file where my dir is and it worked provided that pip install yt-dlp as well.

This is said in the docs:

libmpv.so either locally (in your current working directory) or somewhere in your system library search path.

but could be good to add where to find that file in the docs imho @jaseg

@jaseg
Copy link
Owner

jaseg commented Aug 14, 2024

I have updated the DLL search code to look next to mpv.py, and I have improved on the error messages, which I hope will help with what was mentioned in this issue. These improvements will be in the next release.

On Windows, mpv.py now searches for mpv.dll everywhere in %PATH%, and if it cannot find it there, it will also search the directory mpv.py is in. If nothing is found, you now get the error message from above. Right now, accepted file names are mpv-2.dll, libmpv-2.dll, and mpv-1.dll in that order.

Side note: Relative paths in %PATH% will most likely not work.

Thanks y'all for the reports and comments.

@jaseg jaseg closed this as completed Aug 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants