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

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

Closed
fernandog opened this issue Dec 26, 2016 · 9 comments
Closed

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

fernandog opened this issue Dec 26, 2016 · 9 comments

Comments

@fernandog
Copy link
Contributor

@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
@fernandog
Copy link
Contributor Author

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

@fernandog
Copy link
Contributor Author

fernandog commented Dec 29, 2016

@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)))

@medariox
Copy link
Contributor

labrys added a commit that referenced this issue Jan 3, 2017
Fix #1843: Medusa does not start with Python 2.7.13
@medariox
Copy link
Contributor

medariox commented Jan 3, 2017

Fixed in develop.

@medariox medariox closed this as completed Jan 3, 2017
@imdatacenters
Copy link

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)

@mike-read
Copy link

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.

@engrinak
Copy link

@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?

@oktaygit
Copy link

oktaygit commented Aug 25, 2017

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!

@Ram-Kariapatti
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants