Diego Vieira da Rocha
Diego Vieira da Rocha

Reputation: 11

Module VLC has no attribute Instance

I have this code to play a video on vlc.

import vlc
instance = vlc.Instance('--fullscreen')
player = instance.media_player_new()
Media = instance.media_new('SomethingFromNothing.mkv')
Media.get_mrl()
player.set_media(Media)
player.play()
while True:
    pass

It works fine in python2.7 but I need it to work on python3 and when I run, it shows me this error:

AttributeError: module 'vlc' has no attribute 'Instance'

Upvotes: 0

Views: 1307

Answers (1)

M.Jones
M.Jones

Reputation: 109

You didn't specify if you are using Windows, Mac or Linux, but i also had this problem on Ubuntu 18.04 using Python 3.6.

The error:

AttributeError: module 'vlc' has no attribute 'Instance'

Is due to Python 3.x not being able to find VLC installed on your machine or that you don't have the python bindings installed for Python 3.x

To fix this in Ubuntu Linux, install the python3 bindings for vlc:

sudo pip3 install python-vlc

and install vlc. This is the recommended way of doing so from vlc's website:

sudo snap install vlc

Note however that on my machine i still had problems until i installed vlc using APT:

sudo apt-get install vlc

Upvotes: 1

Related Questions