FileNotFoundError: Could not find module 'libvlc.dll'
Asked Answered
L

10

20

Using Python 3.8.0, 64 bit

OS: Windows 10 Pro, Version 10.0.15063 Build 15063, 64 bit

VLC, 3.0.8 Vetinari, 64 bit

Have installed Python VLC Bindings through PIP

The path to VLC and the direct path to libvlc.dll are both in my “PYTHONPATH” and “PATH” environment variables.

I am running my script via the Windows command prompt.

The script i'm trying to run is one line:

import vlc

Here is what the command prompt is telling me:

Traceback (most recent call last):
  File "001.py", line 1, in <module>
    import vlc
  File "C:\Program Files\Python38\lib\site-packages\vlc.py", line 207, in <module>
    dll, plugin_path  = find_lib()
  File "C:\Program Files\Python38\lib\site-packages\vlc.py", line 163, in find_lib
    dll = ctypes.CDLL(libname)
  File "C:\Program Files\Python38\lib\ctypes\__init__.py", line 369, in __init__
    self._handle = _dlopen(self._name, mode)
FileNotFoundError: Could not find module 'libvlc.dll'. Try using the full path with constructor syntax.

I'm new to Python, any help would be greatly appreciated!

Laclos answered 24/11, 2019 at 3:13 Comment(4)
Where are your libvlc.dll and plugins folder located? Provide full path pleaseAlcahest
This probably isn't the answer a lot of you are looking for, but the original purpose of this script was to download videos from YouTube. I couldn't solve this error at the time, and ended up using youtube-dl to download videos. Thanks to everyone for trying to help!Laclos
@alexacallmebaka, Have you tried WinDLL with winmode flag? This answer helped me with a similar problem as yours.Johnsten
https://mcmap.net/q/21422/-pywin32-and-python-3-8-0Ipecac
N
16

From the Python 3.8 release notes:

DLL dependencies for extension modules and DLLs loaded with ctypes on Windows are now resolved more securely. Only the system paths, the directory containing the DLL or PYD file, and directories added with add_dll_directory() are searched for load-time dependencies. Specifically, PATH and the current working directory are no longer used, and modifications to these will no longer have any effect on normal DLL resolution. If your application relies on these mechanisms, you should check for add_dll_directory() and if it exists, use it to add your DLLs directory while loading your library. Note that Windows 7 users will need to ensure that Windows Update KB2533623 has been installed (this is also verified by the installer).

PATH or cwd cannot be used any more unless you specifically add these directories to the dll search path.

To add cwd to search path:

import os
os.add_dll_directory(os.getcwd())

Most libraries offer an environment variable to specify the dll location. That would load the dll with with the path, something that work.

A lot of packages will have to clean up their library loading for py38 and decide how to handle this. It's currently a source for a lot of confusion.

Nolin answered 24/11, 2019 at 10:57 Comment(3)
This did not work. I added the lines of code you specified to my script, but it still gives me the same error. I also tried running those lines of code in interactive mode, and taking them out of my script, same error.Laclos
So you added the directory the ddl is located to your search path with add_dll_directory? Did you also read and understand the patch notes for py38? You could just throw the dlls into system32 if you don't want to deal with this.Nolin
This comment helped tremendously in isolating an error porting python code from 2.7 to 3.8. Unfortunately, that user also had multiple versions of GCC installed and python 3.8 was pulling in a different GCC version's DLLs vs what python 2.7 was pulling in. So the code ran fine in py2.7 but broke in py3.8. Temporarily solved our problem with just putting the required GCC DLLs into the same directory and then ctypes worked. Any ideas on how to insert a path into the dll directory search list for windows above the end of the list?Schexnayder
U
11

I want to point out that it is possible in 2020 to visit the vlc-website and by clicking on download you will download the 32bit-version of VLC - even though virtually every OS nowadays is 64bit.

In this case libvlc.dll will not be found.

Make sure to install the 64bit-version: https://get.videolan.org/vlc/3.0.11/win64/vlc-3.0.11-win64.exe

No changes in the code are necessary.

Unders answered 6/8, 2020 at 6:46 Comment(1)
apparently in 2024 - still a thing, yes installing 64bit version fixed for me.Peripatetic
D
5

Instead of current directory, add the directory where VLC player is installed.

In my case:

import os
os.add_dll_directory(r'C:\Program Files\VideoLAN\VLC')

import vlc
Dumpling answered 31/12, 2019 at 20:2 Comment(0)
T
4

I download VLC 3.0.7 in case my version of python-vlc is 3.0.7110, then I copy plugins,libvlc.dll and libvlccore.dll to C:\Windows\System32, notes that if your python is 64bit, you need vlc 64bit as well

Tetracycline answered 29/12, 2019 at 0:5 Comment(0)
C
3

This is a combination of other answers. Download the following based on your OS:

Go through the setup process via the dmg/exe. Then execute this before running your code:

import os
os.add_dll_directory(r'C:\Program Files\VideoLAN\VLC')

The code should work perfectly after that.

Campestral answered 1/8, 2021 at 19:25 Comment(1)
VLC now is installed in C:\Program Files\VLC Plus Player but it does not work.Unders
D
1
  1. If path is not added, the problem is that libvlc.dll is not in the PATH(System Variable). Just add the file libvlc.dll path to system variable, this file can be found in the vlc folder where it is installed
  2. Wrong version of VLC, oftenly people download 32bits vlc’s version. This may cause some trouble if we have installed the 64 bits version of python. To fix that, we just need to reinstall the 64 bits vlc’s version.
  3. Import os module prior to vlc module and register libvlc.dll using os.add_dll_directory(r’C:\Program Files\VideoLAN\VLC’).

Source : https://www.geeksforgeeks.org/vlc-module-in-python-an-introduction/

Demoniac answered 21/2, 2021 at 19:0 Comment(0)
M
1

In my case, I have done the following:

  • downloaded VLC 64 bit
  • Copied libvlc.dll and libvlccore.dll to Windows\System32.
  • Used import os, os.add_dll_directory(r'C:\Program Files\VideoLAN\VLC')
Mcintire answered 26/6, 2021 at 15:11 Comment(0)
B
1

This will work:

import subprocess as s
s.call(['C:\\Program Files (x86)\\VideoLAN\\VLC\\vlc.exe', 'voz.mp3', 'vlc://quit'])
Bacteriostasis answered 16/9, 2021 at 19:38 Comment(0)
B
0

I had the same problem. Solution: Download 64bit vlc. https://download.cnet.com/VLC-Media-Player-64-bit/3000-13632_4-75761094.html

Bounteous answered 9/11, 2021 at 10:0 Comment(0)
S
0

You just need to download and install vlc on your computer.

Socinus answered 22/12, 2021 at 15:17 Comment(2)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Wallen
This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From ReviewParley

© 2022 - 2024 — McMap. All rights reserved.