jaseg / python-mpv

Python interface to the awesome mpv media player
https://git.jaseg.de/python-mpv.git
Other
547 stars 68 forks source link

WinError 193/not a valid Win32 application when loading module on Windows #66

Closed blurymind closed 6 years ago

blurymind commented 6 years ago

Here is the backtrace

  File "f:/WORK/PYTHON/webmTest/MPV/webm.py", line 2, in <module>
    import mpv
  File "F:\WORK\PYTHON\WinPython-64bit-3.6.3.0Zero\python-3.6.3.amd64\lib\site-packages\mpv.py", line 31, in <module>
    backend = CDLL('mpv-1.dll')
  File "F:\WORK\PYTHON\WinPython-64bit-3.6.3.0Zero\python-3.6.3.amd64\lib\ctypes\__init__.py", line 348, in __init__
    self._handle = _dlopen(self._name, mode)

I have it placed in the directory where the python script is (webm.py)

soma-gyore commented 6 years ago

Hi,

I assume your error message is "OSError: [WinError 193] %1 is not a valid Win32 application" (it is not on your posted backtrace but I tried to use it with portable python and I received the same error message as you with the oserror).

The problem is that you are trying to use a 32 bit dll with a 64 bit python.

You have two options:

  1. Use 32 bit portable python
  2. Build a 64 bit mpv-1.dll

If you are not familiar with building mpv and you have no reason to use 64bit python the first option is easier.

You should place mpv files where your python.exe is. So I placed mpv.exe, mpv.com and mpv-1.dll to WinPython-32bit-3.6.3.0Zero/python-3.6.3/ (where python.exe is).

I hope this solves your problem. I am just a user of this project and I tried to use it with portable python as you and it throwed error with portable python 64 bit but it worked with portable python 32 bit for me.

I have not tried to build mpv for 64 bit but I assume it is also a good solution.

jaseg commented 6 years ago

@docoprusta Thank you for that explanation.

jaseg commented 6 years ago

I have changed the title of the issue to match the error message @docoprusta mentioned to make this issue easier to find for other people with the same problem.