Skip to content
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

'mpv' module cannot be found #102

Closed
Marcus5408 opened this issue Jan 10, 2023 · 3 comments
Closed

'mpv' module cannot be found #102

Marcus5408 opened this issue Jan 10, 2023 · 3 comments

Comments

@Marcus5408
Copy link

Marcus5408 commented Jan 10, 2023

Describe the bug
anipy-cli fails to load the mpv module even though mpv is installed.

To Reproduce
Steps to reproduce the behavior:

  1. Start anipy-cli
  2. Search for and select an anime, then select an episode
  3. See error

Expected behavior
A mpv window opens and the anime starts playing.

Info

PS C:\Users\Marcus> pip show anipy-cli
Name: anipy-cli
Version: 2.5.10
Summary: Little tool in python to watch anime from the terminal (the better way to watch anime)
Home-page: https://github.com/sdaqo/anipy-cli
Author: sdaqo
Author-email: sdaqo.dev@protonmail.com
License: GPL-3.0
Location: C:\Users\Marcus\AppData\Roaming\Python\Python311\site-packages
Requires: beautifulsoup4, better-ffmpeg-progress, kitsu.py-extended, m3u8, moviepy, pycryptodomex, pypresence, python-dateutil, pyyaml, requests, setuptools, tqdm
Required-by:
PS C:\Users\Marcus>

Platform

  • OS: Windows 11 Pro Insider Preview 22H2 Build 25272.1000
  • Python: 3.11.1
  • mpv: 0.35.0 from chocolatey
  • Windows Terminal: 1.15.3466.0
  • Powershell: Core 7.3.1

Additional context
Exactly what I did to run into the error:

PowerShell 7.3.1
PS C:\Users\Marcus> anipy-cli
Initalized Discord Presence Client
Search: bocchi the rock
[1] Bocchi the Rock!
Enter Number: 1
Episode [1-12]
>> 3
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\Marcus\AppData\Roaming\Python\Python311\Scripts\anipy-cli.exe\__main__.py", line 7, in <module>
  File "C:\Users\Marcus\AppData\Roaming\Python\Python311\site-packages\anipy_cli\run_anipy_cli.py", line 8, in main
    cli.main()
  File "C:\Users\Marcus\AppData\Roaming\Python\Python311\site-packages\anipy_cli\cli.py", line 703, in main
    default_cli(args.quality, player)
  File "C:\Users\Marcus\AppData\Roaming\Python\Python311\site-packages\anipy_cli\cli.py", line 67, in default_cli
    mpv = create_mpv_controllable()
          ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Marcus\AppData\Roaming\Python\Python311\site-packages\anipy_cli\player.py", line 80, in create_mpv_controllable
    import mpv
ModuleNotFoundError: No module named 'mpv'
PS C:\Users\Marcus>

Note: Issue occurs oņ the scoop version of mpv and the Microsoft Store version of mpv as well.

@VoidAny
Copy link
Contributor

VoidAny commented Jan 10, 2023

The reason why this error occurs is because you are using the reuse mpv window option, which calls a function that import a library that was not put into our dependencies list.

So, we forgot to declare a dependency. For a quick fix, you can run python3 -m pip install python-mpv to fix this issue

@VoidAny VoidAny mentioned this issue Jan 10, 2023
@Marcus5408
Copy link
Author

Marcus5408 commented Jan 10, 2023

It's now asking me to include a mpv-1.dll or mpv-2.dll in my system %PATH%, though I don't see to be able to find where I can get this .dll file since it wasn't included with my install.

Edit: I did manage to find a mpv-2.dll file by extracting a 7zip file I found from mpv's sourceforge but it didn't resolve the issue.

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\Marcus\AppData\Roaming\Python\Python311\Scripts\anipy-cli.exe\__main__.py", line 7, in <module>
  File "C:\Users\Marcus\AppData\Roaming\Python\Python311\site-packages\anipy_cli\run_anipy_cli.py", line 8, in main
    cli.main()
  File "C:\Users\Marcus\AppData\Roaming\Python\Python311\site-packages\anipy_cli\cli.py", line 703, in main
    default_cli(args.quality, player)
  File "C:\Users\Marcus\AppData\Roaming\Python\Python311\site-packages\anipy_cli\cli.py", line 67, in default_cli
    mpv = create_mpv_controllable()
          ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Marcus\AppData\Roaming\Python\Python311\site-packages\anipy_cli\player.py", line 80, in create_mpv_controllable
    import mpv
  File "C:\Program Files\Python311\Lib\site-packages\mpv.py", line 35, in <module>
    raise OSError('Cannot find mpv-1.dll or mpv-2.dll in your system %PATH%. One way to deal with this is to ship '
OSError: Cannot find mpv-1.dll or mpv-2.dll in your system %PATH%. One way to deal with this is to ship the 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"].

@sdaqo
Copy link
Owner

sdaqo commented Jan 31, 2023

Please refer to the info in the README I added. It seems the .dll is not on your path. Alternatively, like Dabbing-Guy said, you can deactivate the reuse_mpv_window option in your config.

@sdaqo sdaqo closed this as completed Jan 31, 2023
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

No branches or pull requests

3 participants