Closed ZachaRuba closed 7 years ago
It can't find the libmpv library, so ctypes.util.find_library('mpv-1.dll')
returns None
.
CDLL(None)
throws the above exception.
Encountered a similar error recently, apparently find_library
does not look in the script's location when searching for the library on Windows. Which is unfortunate because on Windows librarys usually get packaged with the application.
Try to replace
backend = CDLL(ctypes.util.find_library('mpv-1.dll'))
with
backend = CDLL('mpv-1.dll')
and it should work.
EDIT:
In case you don't have a mpv-1.dll
yet, you can download one here. (It's included in the Dev-package.)
Hello Frechdachs, Thank you for the response! I didn't have the mpv-1.dll file so I just downloaded it.
1) Changed to
backend = CDLL('mpv-1.dll')
2) Moved
mpv-1.dll
into thelib/site-packages
folder withmpv.py
Different error; still seems that it can't find the file:
OSError: [WinError 126] The specified module could not be found
Since the find_library
does not look in the script's location, I imagine mpv-1.dll
has to be moved somewhere else.
If you are using backend = CDLL('mpv-1.dll')
then python will look for the library in your system search path and the path of YOUR script. (It will not look in the path of mpv.py
)
If you are using backend = CDLL(ctypes.util.find_library('mpv-1.dll'))
then python will only look in the system search path.
So just put it in a directory that's in your Path variable and it should work either way.
@Frechdachs Thank you for the clarification!
I added find_library
after #10, but this looks like not using it might actually be a better idea on windows.
@Frechdachs Thank you!
Moved the 32 version mpv-1.dll
into the same directory as my script testscript.py
that included
import mvp-1.dll
. Working now.
edit: Just tested it with backend = CDLL(ctypes.util.find_library('mpv-1.dll'))
and it still works.
To Recap for those who want to install this using python 3.5 on windows 10;
- python -m pip install https://github.com/jaseg/python-mpv/zipball/master This will download and install the mpv library
- Go to mpv.py in your library. Mine was under;
c://Users/User_Name/AppData/Local/Programs/Python/Python35-32/Lib/site-packages
- Ensure that
backend = CDLL('mpv-1.dll')
in the following statement (found at the top ofmpv.py
)
if os.name == 'nt':
backend = CDLL('mpv-1.dll')
fs_enc = 'utf-8'
else:
- Go here download the latest dev package.
- From the dev pkg, copy the mpv-1.dll file (try 32 version first) and place it in the same directory as your script that is importing the mpv library
*Side note: if you don't want to have to include the mpv-1.dll file everytime in the same directory as your script then place the mpv-1.dll file under your system search path
edit: Just tested it with backend = CDLL(ctypes.util.find_library('mpv-1.dll')) and it still works.
Odd, I tried it on a Windows 8.1 VM and it only found libmpv if I put it in the system search path.
(try 32 version first)
Well, you have to use 32 bit if your python installation is 32 bit and 64 bit if your python installation is 64 bit.
I added find_library after #10, but this looks like not using it might actually be a better idea on windows.
I don't see an advantage of using find_library
on Windows, since apparently you have to specify the full filename anyway.
@jaseg: Oh, and on Linux you should probably check if find_library
returns None
and raise a less cryptic exception.
I pushed a commit that should fix this on both windows and linux. It seems to work for me, but if you are bored feel free to test it. I seem to have some weird problem with the unit tests on my (new) setup right now.
Thank you, that is exactly what I had in mind.
Hello! Running windows 10 with python 3.5.2
To install I used:
python -m pip install https://github.com/jaseg/python-mpv/zipball/master
import mpv gives the error:
Any suggestions?