Search code examples
pythonvlc

module VLC has no attribute MusicPlayer


I'm trying to create a simple script to play an MP3 file using python but I keep getting the error "module VLC has no attribute MusicPlayer" I've checked all the sources I could find but I can't find any reason my code shouldn't work. I've tried reinstalling the module but that hasn't worked. My code it as follows:

import vlc
p = vlc.MediaPlayer("file:OrdisIdle1.mp3")
p.play()

Solution

  • Check where python package vlc is installed in your system. Run dir() from your python interpreter prompt. It will show which packages are available to you. Accessible python packages can controlled through PYTHONPATH environment variable. You should check it as well. This link is useful to understanding how modules are searched when imported from a program.