Medusa: TypeError: LoadLibrary() argument 1 must be string, not unicode

Created on 26 Dec 2016  路  9Comments  路  Source: pymedusa/Medusa

@ratoaq2

Connected to pydev debugger (build 163.9735.8)
Traceback (most recent call last):
  File "C:\Program Files\JetBrains\PyCharm 2016.3\helpers\pydev\pydevd.py", line 1596, in <module>
    globals = debugger.run(setup['file'], None, None, is_module)
  File "C:\Program Files\JetBrains\PyCharm 2016.3\helpers\pydev\pydevd.py", line 974, in run
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "C:/Users/Fernando/Documents/Medusa/start.py", line 4, in <module>
    from medusa.__main__ import main
  File "C:/Users/Fernando/Documents/Medusa\medusa\__main__.py", line 67, in <module>
    from . import (
  File "C:/Users/Fernando/Documents/Medusa\medusa\db.py", line 28, in <module>
    from . import app, logger
  File "C:/Users/Fernando/Documents/Medusa\medusa\logger.py", line 34, in <module>
    import knowit
  File "C:\Users\Fernando\Documents\Medusa\lib\knowit\__init__.py", line 26, in <module>
    from .api import know
  File "C:\Users\Fernando\Documents\Medusa\lib\knowit\api.py", line 10, in <module>
    ('mediainfo', MediaInfoProvider()),
  File "C:\Users\Fernando\Documents\Medusa\lib\knowit\providers\mediainfo.py", line 92, in __init__
    self.native_lib = self._create_native_lib()
  File "C:\Users\Fernando\Documents\Medusa\lib\knowit\providers\mediainfo.py", line 125, in _create_native_lib
    lib = windll.MediaInfo = windll.LoadLibrary(os.path.join(lib, 'MediaInfo.dll'))
  File "C:\Python27\lib\ctypes\__init__.py", line 440, in LoadLibrary
    return self._dlltype(name)
  File "C:\Python27\lib\ctypes\__init__.py", line 362, in __init__
    self._handle = _dlopen(self._name, mode)
TypeError: LoadLibrary() argument 1 must be string, not unicode
Bug Confirmed Upstream

Most helpful comment

If you are using a special version of Python [like Anaconda] and you can't fix it.
Navigate to line 362 of lib/ctypes/__init__.py and change it to:
self._handle = _dlopen(str(self._name), mode)

All 9 comments

i can't debug anymore with pycharm. Can't code anymore lol

@ratoaq2 weird that his happened only now. maybe because of updated 2.7.13 python?

patching mediainfo in knowit lib works:

added str() to os.path.join

\Medusa\lib\knowit\providers\mediainfo.py

logger.debug('Loading native mediainfo library from %s', lib)
lib = windll.MediaInfo = windll.LoadLibrary(str(os.path.join(lib, 'MediaInfo.dll')))

then unrar had the same issue:

\Medusa\lib\unrar2\windows.py

unrar = ctypes.WinDLL(str(os.path.join(os.path.split(__file__)[0], 'UnRARDLL', dll_name)))

Fixed in develop.

If you are using a special version of Python [like Anaconda] and you can't fix it.
Navigate to line 362 of lib/ctypes/__init__.py and change it to:
self._handle = _dlopen(str(self._name), mode)

Thank you! Installed a package on conda, it automatically updated Python to version 2.7.13 and broke everything. This bug causes the python interpreter to immediately exit without any additional output when invoked by typing "python" from within the Anaconda command prompt. And Anaconda will not let you select a previous version of Python. This manual fix did the trick for me.

@imdatacenters I had a similar problem with another python package. I have no idea what I just did, but I followed your recommendation above and it worked. Is this a problem with Anaconda?

Hey, thanks so much. I came across your post while trying to figure out why pytest was giving me the error in the title. But I was pleasantly surprised to discover by @mike-read 's reply that this fix also solved the problem of python interpreter exiting immediately. I had that problem for a while and not from within Anaconda but directly from within the windows command prompt. I was unable to find what caused it and how to solve it but this fix solved it swiftly. So thank you both!

I had faced the same problem. the issue was Python version , It was python 2.7.13 , after updated this by 2.7.14 ,it is resolved.

Also I had reinstalled all the libraries ( it is recommended for my project ) using "pip" in command window.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

wimpyrbx picture wimpyrbx  路  5Comments

Shootersss picture Shootersss  路  3Comments

Rouzax picture Rouzax  路  3Comments

elpedriyo picture elpedriyo  路  4Comments

a10kiloham picture a10kiloham  路  3Comments