Python vlc install problems
Asked Answered
H

4

7

alright so i am trying to install vlc with pip and its telling me successfully installed python-vlc ok good that's what i wanted but when i go to run the program im trying to use vlc in witch is here

import vlc
p = vlc.MediaPlayer("https://www.youtube.com/watch?v=jC1vtG3oyqg")
p.play()

i am told this

Traceback (most recent call last):
  File "C:\Users\Matt\Desktop\test2.py", line 1, in <module>
    import vlc
  File "C:\Python27\lib\site-packages\vlc.py", line 173, in <module>
    dll, plugin_path  = find_lib()
  File "C:\Python27\lib\site-packages\vlc.py", line 150, in find_lib
    dll = ctypes.CDLL('libvlc.dll')
  File "C:\Python27\lib\ctypes\__init__.py", line 365, in __init__
    self._handle = _dlopen(self._name, mode)
WindowsError: [Error 126] The specified module could not be found

im not sure what i am suppose to do since there are errors in the vlc program ( i think ) if you could help me out and get this working for me that would be amazing thank you so much!!

Hexachord answered 4/2, 2017 at 21:36 Comment(6)
can you try where libvlc.dll in a CMD console? you may need to put VLC directory in your PATH.Dayna
im told INFO: Could not find files for the given pattern(s)Hexachord
locate this DLL in your system (using "search") starting in program files (where VLC is installed). Once located, add the location to your path.Dayna
@Jean-FrançoisFabre Hello I am having the same trouble at the moment and u guessed right where libvlc.dll return no PATH (and return an error). But I found it in the folder of VLC. Do you know how i can make windows recognize it.Midshipman
quick hack: I would copy it in C:\Python27\lib\site-packages (same place as the python file) or somewhere you have the path pointing to like C:\windows\system32Dayna
@Jean-FrançoisFabre I answered the question. In Windows you need to set the dll folder to path if you want the system call where works. This fixed the problem for me. Thanks for your helpMidshipman
M
7

Your problem is that libvlc.dll is not in the PATH. There is 2 ways to correct that.

First (temporary):

set PATH=%PATH%;<path to your dll folder>

As explained in the second answer of this post: Adding directory to PATH Environment Variable in Windows

Second (Forever):

This solution makes the variable stay in the path for every reboot of your machine but you need root privilege. As before you need to put the way to your dll folder in the Path variable as explained on this site. (It depends from your system version): https://www.computerhope.com/issues/ch000549.htm

Other problem that may occur

Oftenly, people download 32bits vlc's version. This may cause some trouble if you installed the 64 bits version of python. (Windows Error [193]). To fix that, you just need to reinstall the 64 bits vlc's version.

Midshipman answered 8/11, 2017 at 15:44 Comment(0)
W
3

I had similar question. Here is my solution: First I checked the code in the file __init__.py. Print some variables like self._name and mode to make sure the values are correct. And I looked up the function _dlopen, which is LoadLibrary from _ctypes, and found out the mode argument is optional. So I try to modified the file without breaking the structure of whole file. Here is the code:

the original codes are:

if handle is None:
    self._handle = _dlopen(self._name, mode)
else:
    self._handle = handle

I modified the codes as below:

if handle is None:
    if 'libvlc' not in self._name:
        self._handle = _dlopen(self._name, mode)
    else:  # libvlc.dll will hit
        self._handle = _dlopen(self._name)
else:
    self._handle = handle

And it worked for me. Hope this solution can help people with the same problem.

Wadsworth answered 14/11, 2019 at 8:0 Comment(0)
B
2

I changed my vlc player from 32 bit to 64 and it worked. Just download 64-bit version of vlc player and install it. The write

import vlc

It will work

Broch answered 11/7, 2018 at 18:56 Comment(1)
I can confirm that it works for me too. Thank you! Also, to whom it may concern, I downloaded the 64 bit vlc player from get.videolan.org/vlc/3.0.11/win64/vlc-3.0.11-win64.exeOpenfaced
Q
1

Installing through pip does not install vlc itself, only the python wrapper for the libvlc bindings. To use them, you need to have a working VLC install. Please fetch VLC from www.videolan.org

Quinta answered 26/2, 2017 at 22:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.