3

I just installed python-vlc via pip and when I try

import vlc

The follow error message shows up:

... ...
File "c:\Program Files\Python34\Lib\site-packages\vlc.py", line 173, in <module>
  dll, plugin_path = find_lib()
File "c:\Program Files\Python34\Lib\site-packages\vlc.py", line 150, in find_lib
  dll = ctypes.CDLL('libvlc.dll')
File "c:\Program Files\Python34\Lib\ctypes\__init__.py", line 351, in __init__
  self._handle = _dlopen(self._name, mode)

builtins.OSError: [WinError 126] The specified module could not be found

I am unfamiliar with the ctypes module. What is causing the problem?

3
  • in README.rst, have try this: On win32, the simplest way is to put the vlc.py file in the same directory as the libvlc.dll file (standard location: c:\Program Files\VideoLAN\VLC). Commented May 19, 2017 at 3:49
  • Placed libvlc.dll into \lib\site-packages. Still getting error. Commented May 19, 2017 at 4:51
  • @Victor.L libvlc.dll loads many other VLC components, it needs to stay with the VLC installation. Commented May 19, 2017 at 5:01

4 Answers 4

9

The problem has been solved. I was using 64 bit python and 32 bit VLC. Installing a 64 bit VLC program fixed the problem.

Sign up to request clarification or add additional context in comments.

Comments

3

python-vlc on Windows needs to load libvlc.dll from VLC. If it's not found in the normal %PATH%, it will try to use pywin32 to look in the registry to find the VLC install path, and fall back to a hard-coded set of directories after that. The stack trace looks like all of that failed.

Do you have VLC installed?

2 Comments

I just installed VLC and rebooted. Still getting the same error. (win8.1 x64)
@Victor.L If you don't have pywin32 installed, it will search in %ProgramFiles%\VideoLan\VLC, %HOMEDRIVE%:\VideoLan\VLC, %ProgramFiles%\VLC, and %HOMEDRIVE%:\VLC. If those environment variables aren't set or VLC isn't installed there, it still won't work. I would suggest running your program from within the VLC install directory to see if that works.
0

You are installed VLC 32 bit hence your path goes to program file (x86) and your code search the VLC file in programs file. That's why you are getting this error. To solve this problem we need to install VLC for 64 bits.

Comments

0

I ran into the same problem. To fix it I actually had to install the x86 version NOT the x64bit version... no matter what I did it would not work. I figured this out through looking at the code it was using to find the path. Used a breakpoint to see what it was seeing in the exists flow and what it was searching :

C:<Your Python Path>\Lib\site-packages\vlc.py

 if plugin_path is None:
            # try some standard locations.
            programfiles = os.environ["ProgramFiles"]
            homedir = os.environ["HOMEDRIVE"]
            for p in ('{programfiles}\\VideoLan{libname}', '{homedir}:\\VideoLan{libname}',
                      '{programfiles}{libname}',           '{homedir}:{libname}'):
                p = p.format(homedir = homedir,
                             programfiles = programfiles,
                             libname = '\\VLC\\' + libname)
                if os.path.exists(p):
                    plugin_path = os.path.dirname(p)

Hope it helps someone :)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.