pythonvlcpython-vlc

" No module named 'vlc' " - trouble importing VLC with Python


I am trying to use the python-vlc library in python and keep getting errors when using "import vlc".

I have the 64-bit Windows version of VLC player installed, and am using Python version 3.9.6 in a virtual environment in Visual Studio. My version of Windows is also 64-bit.

I used "pip install python-vlc" to download the module from the terminal within the project's virtual environment and confirmed that it downloaded correctly.

Here's the code I'm using:

try:
    import vlc
except:
    from os import environ
    vlc_path = 'C:\Program Files\VideoLAN\VLC'
    environ['PATH'] += ';' + vlc_path
    import vlc

When running this in Visual Studio I get the error:

No module named 'vlc'

Any help would be greatly appreciated.

Thanks a lot.


Solution

  • You can install library locally by doing pip install -t . python-vlc --no-user and try to import it (you will download a vlc.py file to your project folder and you can try to import it)