Python Forum

Full Version: Annoying BeautifulSoup user warning.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Hello,

I have the following code:
GUI.py
from PySide import QtCore, QtGui

class Graphics(object):
    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(1125, 865)
        self.centralwidget = QtGui.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.playlist = QtGui.QListView(self.centralwidget)
        self.playlist.setGeometry(QtCore.QRect(10, 40, 301, 801))
        self.playlist.setObjectName("playlist")
        self.lyrics = QtGui.QTextBrowser(self.centralwidget)
        self.lyrics.setGeometry(QtCore.QRect(810, 40, 301, 801))
        self.lyrics.setObjectName("lyrics")
        self.albumArt = QtGui.QGraphicsView(self.centralwidget)
        self.albumArt.setGeometry(QtCore.QRect(325, 40, 471, 431))
        self.albumArt.setObjectName("albumArt")
        self.openFileButton = QtGui.QPushButton(self.centralwidget)
        self.openFileButton.setGeometry(QtCore.QRect(520, 10, 75, 23))
        self.openFileButton.setObjectName("openFileButton")
        self.songName = QtGui.QLabel(self.centralwidget)
        self.songName.setGeometry(QtCore.QRect(330, 640, 461, 21))
        self.songName.setObjectName("songName")
        self.artistName = QtGui.QLabel(self.centralwidget)
        self.artistName.setGeometry(QtCore.QRect(330, 670, 461, 21))
        self.artistName.setObjectName("artistName")
        self.albumName = QtGui.QLabel(self.centralwidget)
        self.albumName.setGeometry(QtCore.QRect(330, 700, 461, 21))
        self.albumName.setObjectName("albumName")
        self.songsCount = QtGui.QLabel(self.centralwidget)
        self.songsCount.setGeometry(QtCore.QRect(740, 670, 61, 21))
        self.songsCount.setObjectName("songsCount")
        self.seekSlider = QtGui.QSlider(self.centralwidget)
        self.seekSlider.setGeometry(QtCore.QRect(330, 500, 461, 22))
        self.seekSlider.setOrientation(QtCore.Qt.Horizontal)
        self.seekSlider.setObjectName("seekSlider")
        self.volumeSlider = QtGui.QSlider(self.centralwidget)
        self.volumeSlider.setGeometry(QtCore.QRect(330, 780, 461, 22))
        self.volumeSlider.setOrientation(QtCore.Qt.Horizontal)
        self.volumeSlider.setObjectName("volumeSlider")
        self.seekLabel = QtGui.QLabel(self.centralwidget)
        self.seekLabel.setGeometry(QtCore.QRect(330, 480, 461, 20))
        self.seekLabel.setObjectName("seekLabel")
        self.prevSongButton = QtGui.QPushButton(self.centralwidget)
        self.prevSongButton.setGeometry(QtCore.QRect(440, 550, 71, 71))
        self.prevSongButton.setText("")
        self.prevSongButton.setIconSize(QtCore.QSize(80, 80))
        self.prevSongButton.setObjectName("prevSongButton")
        self.playPauseButton = QtGui.QPushButton(self.centralwidget)
        self.playPauseButton.setGeometry(QtCore.QRect(520, 550, 81, 71))
        self.playPauseButton.setText("")
        self.playPauseButton.setIconSize(QtCore.QSize(80, 80))
        self.playPauseButton.setObjectName("playPauseButton")
        self.nextSongButton = QtGui.QPushButton(self.centralwidget)
        self.nextSongButton.setGeometry(QtCore.QRect(610, 550, 71, 71))
        self.nextSongButton.setText("")
        self.nextSongButton.setIconSize(QtCore.QSize(80, 80))
        self.nextSongButton.setObjectName("nextSongButton")
        self.volumeLabel = QtGui.QLabel(self.centralwidget)
        self.volumeLabel.setGeometry(QtCore.QRect(330, 760, 461, 20))
        self.volumeLabel.setObjectName("volumeLabel")
        MainWindow.setCentralWidget(self.centralwidget)
        self.statusbar = QtGui.QStatusBar(MainWindow)
        self.statusbar.setObjectName("statusbar")
        MainWindow.setStatusBar(self.statusbar)

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)

    def retranslateUi(self, MainWindow):
        MainWindow.setWindowTitle(QtGui.QApplication.translate("MainWindow", "MainWindow", None, QtGui.QApplication.UnicodeUTF8))
        self.lyrics.setHtml(QtGui.QApplication.translate("MainWindow", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
"</style></head><body style=\" font-family:\'MS Shell Dlg 2\'; font-size:8.25pt; font-weight:400; font-style:normal;\">\n"
"<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br /></p></body></html>", None, QtGui.QApplication.UnicodeUTF8))
        self.openFileButton.setText(QtGui.QApplication.translate("MainWindow", "Open File", None, QtGui.QApplication.UnicodeUTF8))
        self.songName.setText(QtGui.QApplication.translate("MainWindow", "Song:  ", None, QtGui.QApplication.UnicodeUTF8))
        self.artistName.setText(QtGui.QApplication.translate("MainWindow", "Artist:  ", None, QtGui.QApplication.UnicodeUTF8))
        self.albumName.setText(QtGui.QApplication.translate("MainWindow", "Album: ", None, QtGui.QApplication.UnicodeUTF8))
        self.songsCount.setText(QtGui.QApplication.translate("MainWindow", "0 / 0", None, QtGui.QApplication.UnicodeUTF8))
        self.seekLabel.setText(QtGui.QApplication.translate("MainWindow", "<html><head/><body><p align=\"center\">Seek</p></body></html>", None, QtGui.QApplication.UnicodeUTF8))
        self.volumeLabel.setText(QtGui.QApplication.translate("MainWindow", "<html><head/><body><p align=\"center\">Volume</p></body></html>", None, QtGui.QApplication.UnicodeUTF8))
MusicPlayer.py
import sys, tkinter, pygame, mutagen
from tkinter import filedialog
#from mutagen import File
from mutagen.easyid3 import EasyID3
from PyLyrics import *
from PySide.QtCore import *
from PySide.QtGui import *
from GUI import *
  
class MusicPlayer(QMainWindow, Graphics):
	def __init__(self, parent = None):
		super(MusicPlayer, self).__init__(parent)
		self.setupUi(self)
		pygame.init()
		pygame.mixer.init()
		self.openFileButton.clicked.connect(self.openFileSelectionDialog)
		self.prevIcon = QtGui.QIcon()
		self.prevIconImage = QtGui.QPixmap("icons/prevButton.png")
		self.prevIcon.addPixmap(self.prevIconImage)
		self.prevSongButton.setIcon(self.prevIcon)
		self.playIcon = QtGui.QIcon()
		self.playIconImage = QtGui.QPixmap("icons/playButton.png")
		self.playIcon.addPixmap(self.playIconImage)
		self.playPauseButton.setIcon(self.playIcon)
		self.pauseIcon = QtGui.QIcon()
		self.pauseIconImage = QtGui.QPixmap("icons/pauseButton.png")
		self.pauseIcon.addPixmap(self.pauseIconImage)
		self.nextIcon = QtGui.QIcon()
		self.nextIconImage = QtGui.QPixmap("icons/nextButton.png")
		self.nextIcon.addPixmap(self.nextIconImage)
		self.nextSongButton.setIcon(self.nextIcon)
		self.seekSlider.setValue(0)
		self.volumeSlider.setValue(0)
		self.prevSongButton.clicked.connect(self.previousSongAudioButton)
		self.nextSongButton.clicked.connect(self.nextSongAudioButton)
		self.previousButtonPressed = False
		self.isPlaying = False
		self.volumeSlider.setRange(0, 100)
	
	def openFileSelectionDialog(self):
		root = tkinter.Tk()
		root.withdraw()
		self.file_path = filedialog.askopenfilename()
		self.playAudioFromSelectedFile(self.file_path)
		
	def playAudioFromSelectedFile(self, path):
		pygame.mixer.music.load(path)
		pygame.mixer.music.play()
		self.showSongInfo(path)
		self.playPauseButton.setIcon(self.pauseIcon)
		self.playPauseButton.setEnabled(True)
		self.seekSlider.setEnabled(True)
		self.playPauseButton.clicked.connect(self.playPauseAudioButton)
		self.isPlaying = True
	
	def playPauseAudioButton(self):
		if self.isPlaying == True:
			pygame.mixer.music.pause()
			self.playPauseButton.setIcon(self.playIcon)
			self.isPlaying = False
		elif self.isPlaying == False:
			if self.previousButtonPressed == True:
				pygame.mixer.music.play()
			elif self.previousButtonPressed == False:
				pygame.mixer.music.unpause()
			self.playPauseButton.setIcon(self.pauseIcon)
			self.isPlaying = True
		
	def previousSongAudioButton(self):
		if self.isPlaying == True:
			pygame.mixer.music.stop()
			pygame.mixer.music.play()
		elif self.isPlaying == False:
			pygame.mixer.music.stop()
			pygame.mixer.music.load(self.file_path)
			self.previousButtonPressed = True
		
	def nextSongAudioButton(self):
		if self.isPlaying == True:
			pygame.mixer.music.stop()
		
	def showSongInfo(self, path):
		'''self.filePath = File(path)
		self.artwork = self.filePath.tags['APIC:'].data
		self.albumArtImage = QImage(self.artwork)
		self.pixmapItem = QGraphicsPixmapItem(QPixmap.fromImage(self.albumArtImage))
		self.scene = QGraphicsScene()
		scene.addItem(self.pixmapItem)
		self.albumArt.setScene(self.scene)'''
		#print(EasyID3.valid_keys.keys())
		self.audioFile = EasyID3(path)
		self.songName.setText("Song:  " + self.audioFile["title"][0])
		self.artistName.setText("Artist:  " + self.audioFile["artist"][0])
		self.albumName.setText("Album: " + self.audioFile["album"][0])
		self.lyrics.setText(PyLyrics.getLyrics(self.audioFile["artist"][0], self.audioFile["title"][0]))
	
if __name__ == "__main__":
	app = QApplication(sys.argv)
	window = MusicPlayer()
	window.show()
	sys.exit(app.exec_())
And I get the warning:
Quote:UserWarning: No parser was explicitly specified, so I'm using the best
available HTML parser for this system ("html.parser"). This usually isn't a
problem, but if you run this code on another system, or in a different
virtual environment, it may use a different parser and behave differently.

The code that caused this warning is on line 101 of the file MusicPlayer.py
To get rid of this warning, change this:

BeautifulSoup([your markup])

to this:

BeautifulSoup([your markup], "html.parser")

But never in my code have I used "BeautifulSoup" at all! So I can't change it as suggested by the message...
How can I remove or fix this annoying warning? The program works fine, I just don't like errors in the console.
PyLyrics is the module that uses BeatifulSoup in some way, but I don't know how to get rid of the warning. Help :(

PS: It says that it's caused on line 101, but it's not if you look at that line.
Looks like at least 4 different people have solved that issue: https://github.com/geekpradd/PyLyrics/pulls
However, none were merged in, and the last commit was 2 years ago, which leads me to believe the package has been abandoned. If you look at one of the changelogs, you'll see it's only 3 lines that need updating, so maybe you can do it yourself? https://github.com/geekpradd/PyLyrics/pu...970bcf19f5
As far as i know the only way to get rid of the warning is to give BeautifulSoup class a second arg defining the parser you want. Without a second arg for a parser, you will get this warning.

You could go into PyLyrics source and change the code from
Quote:BeautifulSoup([your markup])

to this:

BeautifulSoup([your markup], "html.parser")

There are 3 times it calls bs4 here that needs changing
https://github.com/geekpradd/PyLyrics/bl...nctions.py

all you have to do is add the following code within the parenthesis, but after the original argument
, 'html.parser'
in each line
BeautifulSoup(WHATEVER_WAS_HERE.text, 'html.parser')
(May-10-2018, 07:00 PM)MegasXLR Wrote: [ -> ]Hello,

I have the following code:
GUI.py
from PySide import QtCore, QtGui

class Graphics(object):
    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(1125, 865)
        self.centralwidget = QtGui.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.playlist = QtGui.QListView(self.centralwidget)
        self.playlist.setGeometry(QtCore.QRect(10, 40, 301, 801))
        self.playlist.setObjectName("playlist")
        self.lyrics = QtGui.QTextBrowser(self.centralwidget)
        self.lyrics.setGeometry(QtCore.QRect(810, 40, 301, 801))
        self.lyrics.setObjectName("lyrics")
        self.albumArt = QtGui.QGraphicsView(self.centralwidget)
        self.albumArt.setGeometry(QtCore.QRect(325, 40, 471, 431))
        self.albumArt.setObjectName("albumArt")
        self.openFileButton = QtGui.QPushButton(self.centralwidget)
        self.openFileButton.setGeometry(QtCore.QRect(520, 10, 75, 23))
        self.openFileButton.setObjectName("openFileButton")
        self.songName = QtGui.QLabel(self.centralwidget)
        self.songName.setGeometry(QtCore.QRect(330, 640, 461, 21))
        self.songName.setObjectName("songName")
        self.artistName = QtGui.QLabel(self.centralwidget)
        self.artistName.setGeometry(QtCore.QRect(330, 670, 461, 21))
        self.artistName.setObjectName("artistName")
        self.albumName = QtGui.QLabel(self.centralwidget)
        self.albumName.setGeometry(QtCore.QRect(330, 700, 461, 21))
        self.albumName.setObjectName("albumName")
        self.songsCount = QtGui.QLabel(self.centralwidget)
        self.songsCount.setGeometry(QtCore.QRect(740, 670, 61, 21))
        self.songsCount.setObjectName("songsCount")
        self.seekSlider = QtGui.QSlider(self.centralwidget)
        self.seekSlider.setGeometry(QtCore.QRect(330, 500, 461, 22))
        self.seekSlider.setOrientation(QtCore.Qt.Horizontal)
        self.seekSlider.setObjectName("seekSlider")
        self.volumeSlider = QtGui.QSlider(self.centralwidget)
        self.volumeSlider.setGeometry(QtCore.QRect(330, 780, 461, 22))
        self.volumeSlider.setOrientation(QtCore.Qt.Horizontal)
        self.volumeSlider.setObjectName("volumeSlider")
        self.seekLabel = QtGui.QLabel(self.centralwidget)
        self.seekLabel.setGeometry(QtCore.QRect(330, 480, 461, 20))
        self.seekLabel.setObjectName("seekLabel")
        self.prevSongButton = QtGui.QPushButton(self.centralwidget)
        self.prevSongButton.setGeometry(QtCore.QRect(440, 550, 71, 71))
        self.prevSongButton.setText("")
        self.prevSongButton.setIconSize(QtCore.QSize(80, 80))
        self.prevSongButton.setObjectName("prevSongButton")
        self.playPauseButton = QtGui.QPushButton(self.centralwidget)
        self.playPauseButton.setGeometry(QtCore.QRect(520, 550, 81, 71))
        self.playPauseButton.setText("")
        self.playPauseButton.setIconSize(QtCore.QSize(80, 80))
        self.playPauseButton.setObjectName("playPauseButton")
        self.nextSongButton = QtGui.QPushButton(self.centralwidget)
        self.nextSongButton.setGeometry(QtCore.QRect(610, 550, 71, 71))
        self.nextSongButton.setText("")
        self.nextSongButton.setIconSize(QtCore.QSize(80, 80))
        self.nextSongButton.setObjectName("nextSongButton")
        self.volumeLabel = QtGui.QLabel(self.centralwidget)
        self.volumeLabel.setGeometry(QtCore.QRect(330, 760, 461, 20))
        self.volumeLabel.setObjectName("volumeLabel")
        MainWindow.setCentralWidget(self.centralwidget)
        self.statusbar = QtGui.QStatusBar(MainWindow)
        self.statusbar.setObjectName("statusbar")
        MainWindow.setStatusBar(self.statusbar)

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)

    def retranslateUi(self, MainWindow):
        MainWindow.setWindowTitle(QtGui.QApplication.translate("MainWindow", "MainWindow", None, QtGui.QApplication.UnicodeUTF8))
        self.lyrics.setHtml(QtGui.QApplication.translate("MainWindow", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
"</style></head><body style=\" font-family:\'MS Shell Dlg 2\'; font-size:8.25pt; font-weight:400; font-style:normal;\">\n"
"<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br /></p></body></html>", None, QtGui.QApplication.UnicodeUTF8))
        self.openFileButton.setText(QtGui.QApplication.translate("MainWindow", "Open File", None, QtGui.QApplication.UnicodeUTF8))
        self.songName.setText(QtGui.QApplication.translate("MainWindow", "Song:  ", None, QtGui.QApplication.UnicodeUTF8))
        self.artistName.setText(QtGui.QApplication.translate("MainWindow", "Artist:  ", None, QtGui.QApplication.UnicodeUTF8))
        self.albumName.setText(QtGui.QApplication.translate("MainWindow", "Album: ", None, QtGui.QApplication.UnicodeUTF8))
        self.songsCount.setText(QtGui.QApplication.translate("MainWindow", "0 / 0", None, QtGui.QApplication.UnicodeUTF8))
        self.seekLabel.setText(QtGui.QApplication.translate("MainWindow", "<html><head/><body><p align=\"center\">Seek</p></body></html>", None, QtGui.QApplication.UnicodeUTF8))
        self.volumeLabel.setText(QtGui.QApplication.translate("MainWindow", "<html><head/><body><p align=\"center\">Volume</p></body></html>", None, QtGui.QApplication.UnicodeUTF8))
MusicPlayer.py
import sys, tkinter, pygame, mutagen
from tkinter import filedialog
#from mutagen import File
from mutagen.easyid3 import EasyID3
from PyLyrics import *
from PySide.QtCore import *
from PySide.QtGui import *
from GUI import *
  
class MusicPlayer(QMainWindow, Graphics):
	def __init__(self, parent = None):
		super(MusicPlayer, self).__init__(parent)
		self.setupUi(self)
		pygame.init()
		pygame.mixer.init()
		self.openFileButton.clicked.connect(self.openFileSelectionDialog)
		self.prevIcon = QtGui.QIcon()
		self.prevIconImage = QtGui.QPixmap("icons/prevButton.png")
		self.prevIcon.addPixmap(self.prevIconImage)
		self.prevSongButton.setIcon(self.prevIcon)
		self.playIcon = QtGui.QIcon()
		self.playIconImage = QtGui.QPixmap("icons/playButton.png")
		self.playIcon.addPixmap(self.playIconImage)
		self.playPauseButton.setIcon(self.playIcon)
		self.pauseIcon = QtGui.QIcon()
		self.pauseIconImage = QtGui.QPixmap("icons/pauseButton.png")
		self.pauseIcon.addPixmap(self.pauseIconImage)
		self.nextIcon = QtGui.QIcon()
		self.nextIconImage = QtGui.QPixmap("icons/nextButton.png")
		self.nextIcon.addPixmap(self.nextIconImage)
		self.nextSongButton.setIcon(self.nextIcon)
		self.seekSlider.setValue(0)
		self.volumeSlider.setValue(0)
		self.prevSongButton.clicked.connect(self.previousSongAudioButton)
		self.nextSongButton.clicked.connect(self.nextSongAudioButton)
		self.previousButtonPressed = False
		self.isPlaying = False
		self.volumeSlider.setRange(0, 100)
	
	def openFileSelectionDialog(self):
		root = tkinter.Tk()
		root.withdraw()
		self.file_path = filedialog.askopenfilename()
		self.playAudioFromSelectedFile(self.file_path)
		
	def playAudioFromSelectedFile(self, path):
		pygame.mixer.music.load(path)
		pygame.mixer.music.play()
		self.showSongInfo(path)
		self.playPauseButton.setIcon(self.pauseIcon)
		self.playPauseButton.setEnabled(True)
		self.seekSlider.setEnabled(True)
		self.playPauseButton.clicked.connect(self.playPauseAudioButton)
		self.isPlaying = True
	
	def playPauseAudioButton(self):
		if self.isPlaying == True:
			pygame.mixer.music.pause()
			self.playPauseButton.setIcon(self.playIcon)
			self.isPlaying = False
		elif self.isPlaying == False:
			if self.previousButtonPressed == True:
				pygame.mixer.music.play()
			elif self.previousButtonPressed == False:
				pygame.mixer.music.unpause()
			self.playPauseButton.setIcon(self.pauseIcon)
			self.isPlaying = True
		
	def previousSongAudioButton(self):
		if self.isPlaying == True:
			pygame.mixer.music.stop()
			pygame.mixer.music.play()
		elif self.isPlaying == False:
			pygame.mixer.music.stop()
			pygame.mixer.music.load(self.file_path)
			self.previousButtonPressed = True
		
	def nextSongAudioButton(self):
		if self.isPlaying == True:
			pygame.mixer.music.stop()
		
	def showSongInfo(self, path):
		'''self.filePath = File(path)
		self.artwork = self.filePath.tags['APIC:'].data
		self.albumArtImage = QImage(self.artwork)
		self.pixmapItem = QGraphicsPixmapItem(QPixmap.fromImage(self.albumArtImage))
		self.scene = QGraphicsScene()
		scene.addItem(self.pixmapItem)
		self.albumArt.setScene(self.scene)'''
		#print(EasyID3.valid_keys.keys())
		self.audioFile = EasyID3(path)
		self.songName.setText("Song:  " + self.audioFile["title"][0])
		self.artistName.setText("Artist:  " + self.audioFile["artist"][0])
		self.albumName.setText("Album: " + self.audioFile["album"][0])
		self.lyrics.setText(PyLyrics.getLyrics(self.audioFile["artist"][0], self.audioFile["title"][0]))
	
if __name__ == "__main__":
	app = QApplication(sys.argv)
	window = MusicPlayer()
	window.show()
	sys.exit(app.exec_())
But never in my code have I used "BeautifulSoup" at all! So I can't change it as suggested by the message...
How can I remove or fix this annoying warning? The program works fine, I just don't like errors in the console.
PyLyrics is the module that uses BeatifulSoup in some way, but I don't know how to get rid of the warning. Help :(

PS: It says that it's caused on line 101, but it's not if you look at that line.

actually you are using BeautifulSoup (indirectly). In your GUI file you are calling the setHtml function of the QTextBrowser item "lyrics". At least that is the only part where it might be called.
The interesting part is, that my system does not show any warning at all.
Since creating the MusicPlayer object does not throw any warning I do not think the problem is in your PyLyrics file. So the setHtml function could be the reason.
(May-11-2018, 07:48 AM)ThiefOfTime Wrote: [ -> ]
(May-10-2018, 07:00 PM)MegasXLR Wrote: [ -> ]Hello,

I have the following code:
GUI.py
from PySide import QtCore, QtGui

class Graphics(object):
    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(1125, 865)
        self.centralwidget = QtGui.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.playlist = QtGui.QListView(self.centralwidget)
        self.playlist.setGeometry(QtCore.QRect(10, 40, 301, 801))
        self.playlist.setObjectName("playlist")
        self.lyrics = QtGui.QTextBrowser(self.centralwidget)
        self.lyrics.setGeometry(QtCore.QRect(810, 40, 301, 801))
        self.lyrics.setObjectName("lyrics")
        self.albumArt = QtGui.QGraphicsView(self.centralwidget)
        self.albumArt.setGeometry(QtCore.QRect(325, 40, 471, 431))
        self.albumArt.setObjectName("albumArt")
        self.openFileButton = QtGui.QPushButton(self.centralwidget)
        self.openFileButton.setGeometry(QtCore.QRect(520, 10, 75, 23))
        self.openFileButton.setObjectName("openFileButton")
        self.songName = QtGui.QLabel(self.centralwidget)
        self.songName.setGeometry(QtCore.QRect(330, 640, 461, 21))
        self.songName.setObjectName("songName")
        self.artistName = QtGui.QLabel(self.centralwidget)
        self.artistName.setGeometry(QtCore.QRect(330, 670, 461, 21))
        self.artistName.setObjectName("artistName")
        self.albumName = QtGui.QLabel(self.centralwidget)
        self.albumName.setGeometry(QtCore.QRect(330, 700, 461, 21))
        self.albumName.setObjectName("albumName")
        self.songsCount = QtGui.QLabel(self.centralwidget)
        self.songsCount.setGeometry(QtCore.QRect(740, 670, 61, 21))
        self.songsCount.setObjectName("songsCount")
        self.seekSlider = QtGui.QSlider(self.centralwidget)
        self.seekSlider.setGeometry(QtCore.QRect(330, 500, 461, 22))
        self.seekSlider.setOrientation(QtCore.Qt.Horizontal)
        self.seekSlider.setObjectName("seekSlider")
        self.volumeSlider = QtGui.QSlider(self.centralwidget)
        self.volumeSlider.setGeometry(QtCore.QRect(330, 780, 461, 22))
        self.volumeSlider.setOrientation(QtCore.Qt.Horizontal)
        self.volumeSlider.setObjectName("volumeSlider")
        self.seekLabel = QtGui.QLabel(self.centralwidget)
        self.seekLabel.setGeometry(QtCore.QRect(330, 480, 461, 20))
        self.seekLabel.setObjectName("seekLabel")
        self.prevSongButton = QtGui.QPushButton(self.centralwidget)
        self.prevSongButton.setGeometry(QtCore.QRect(440, 550, 71, 71))
        self.prevSongButton.setText("")
        self.prevSongButton.setIconSize(QtCore.QSize(80, 80))
        self.prevSongButton.setObjectName("prevSongButton")
        self.playPauseButton = QtGui.QPushButton(self.centralwidget)
        self.playPauseButton.setGeometry(QtCore.QRect(520, 550, 81, 71))
        self.playPauseButton.setText("")
        self.playPauseButton.setIconSize(QtCore.QSize(80, 80))
        self.playPauseButton.setObjectName("playPauseButton")
        self.nextSongButton = QtGui.QPushButton(self.centralwidget)
        self.nextSongButton.setGeometry(QtCore.QRect(610, 550, 71, 71))
        self.nextSongButton.setText("")
        self.nextSongButton.setIconSize(QtCore.QSize(80, 80))
        self.nextSongButton.setObjectName("nextSongButton")
        self.volumeLabel = QtGui.QLabel(self.centralwidget)
        self.volumeLabel.setGeometry(QtCore.QRect(330, 760, 461, 20))
        self.volumeLabel.setObjectName("volumeLabel")
        MainWindow.setCentralWidget(self.centralwidget)
        self.statusbar = QtGui.QStatusBar(MainWindow)
        self.statusbar.setObjectName("statusbar")
        MainWindow.setStatusBar(self.statusbar)

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)

    def retranslateUi(self, MainWindow):
        MainWindow.setWindowTitle(QtGui.QApplication.translate("MainWindow", "MainWindow", None, QtGui.QApplication.UnicodeUTF8))
        self.lyrics.setHtml(QtGui.QApplication.translate("MainWindow", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
"</style></head><body style=\" font-family:\'MS Shell Dlg 2\'; font-size:8.25pt; font-weight:400; font-style:normal;\">\n"
"<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br /></p></body></html>", None, QtGui.QApplication.UnicodeUTF8))
        self.openFileButton.setText(QtGui.QApplication.translate("MainWindow", "Open File", None, QtGui.QApplication.UnicodeUTF8))
        self.songName.setText(QtGui.QApplication.translate("MainWindow", "Song:  ", None, QtGui.QApplication.UnicodeUTF8))
        self.artistName.setText(QtGui.QApplication.translate("MainWindow", "Artist:  ", None, QtGui.QApplication.UnicodeUTF8))
        self.albumName.setText(QtGui.QApplication.translate("MainWindow", "Album: ", None, QtGui.QApplication.UnicodeUTF8))
        self.songsCount.setText(QtGui.QApplication.translate("MainWindow", "0 / 0", None, QtGui.QApplication.UnicodeUTF8))
        self.seekLabel.setText(QtGui.QApplication.translate("MainWindow", "<html><head/><body><p align=\"center\">Seek</p></body></html>", None, QtGui.QApplication.UnicodeUTF8))
        self.volumeLabel.setText(QtGui.QApplication.translate("MainWindow", "<html><head/><body><p align=\"center\">Volume</p></body></html>", None, QtGui.QApplication.UnicodeUTF8))
MusicPlayer.py
import sys, tkinter, pygame, mutagen
from tkinter import filedialog
#from mutagen import File
from mutagen.easyid3 import EasyID3
from PyLyrics import *
from PySide.QtCore import *
from PySide.QtGui import *
from GUI import *
  
class MusicPlayer(QMainWindow, Graphics):
	def __init__(self, parent = None):
		super(MusicPlayer, self).__init__(parent)
		self.setupUi(self)
		pygame.init()
		pygame.mixer.init()
		self.openFileButton.clicked.connect(self.openFileSelectionDialog)
		self.prevIcon = QtGui.QIcon()
		self.prevIconImage = QtGui.QPixmap("icons/prevButton.png")
		self.prevIcon.addPixmap(self.prevIconImage)
		self.prevSongButton.setIcon(self.prevIcon)
		self.playIcon = QtGui.QIcon()
		self.playIconImage = QtGui.QPixmap("icons/playButton.png")
		self.playIcon.addPixmap(self.playIconImage)
		self.playPauseButton.setIcon(self.playIcon)
		self.pauseIcon = QtGui.QIcon()
		self.pauseIconImage = QtGui.QPixmap("icons/pauseButton.png")
		self.pauseIcon.addPixmap(self.pauseIconImage)
		self.nextIcon = QtGui.QIcon()
		self.nextIconImage = QtGui.QPixmap("icons/nextButton.png")
		self.nextIcon.addPixmap(self.nextIconImage)
		self.nextSongButton.setIcon(self.nextIcon)
		self.seekSlider.setValue(0)
		self.volumeSlider.setValue(0)
		self.prevSongButton.clicked.connect(self.previousSongAudioButton)
		self.nextSongButton.clicked.connect(self.nextSongAudioButton)
		self.previousButtonPressed = False
		self.isPlaying = False
		self.volumeSlider.setRange(0, 100)
	
	def openFileSelectionDialog(self):
		root = tkinter.Tk()
		root.withdraw()
		self.file_path = filedialog.askopenfilename()
		self.playAudioFromSelectedFile(self.file_path)
		
	def playAudioFromSelectedFile(self, path):
		pygame.mixer.music.load(path)
		pygame.mixer.music.play()
		self.showSongInfo(path)
		self.playPauseButton.setIcon(self.pauseIcon)
		self.playPauseButton.setEnabled(True)
		self.seekSlider.setEnabled(True)
		self.playPauseButton.clicked.connect(self.playPauseAudioButton)
		self.isPlaying = True
	
	def playPauseAudioButton(self):
		if self.isPlaying == True:
			pygame.mixer.music.pause()
			self.playPauseButton.setIcon(self.playIcon)
			self.isPlaying = False
		elif self.isPlaying == False:
			if self.previousButtonPressed == True:
				pygame.mixer.music.play()
			elif self.previousButtonPressed == False:
				pygame.mixer.music.unpause()
			self.playPauseButton.setIcon(self.pauseIcon)
			self.isPlaying = True
		
	def previousSongAudioButton(self):
		if self.isPlaying == True:
			pygame.mixer.music.stop()
			pygame.mixer.music.play()
		elif self.isPlaying == False:
			pygame.mixer.music.stop()
			pygame.mixer.music.load(self.file_path)
			self.previousButtonPressed = True
		
	def nextSongAudioButton(self):
		if self.isPlaying == True:
			pygame.mixer.music.stop()
		
	def showSongInfo(self, path):
		'''self.filePath = File(path)
		self.artwork = self.filePath.tags['APIC:'].data
		self.albumArtImage = QImage(self.artwork)
		self.pixmapItem = QGraphicsPixmapItem(QPixmap.fromImage(self.albumArtImage))
		self.scene = QGraphicsScene()
		scene.addItem(self.pixmapItem)
		self.albumArt.setScene(self.scene)'''
		#print(EasyID3.valid_keys.keys())
		self.audioFile = EasyID3(path)
		self.songName.setText("Song:  " + self.audioFile["title"][0])
		self.artistName.setText("Artist:  " + self.audioFile["artist"][0])
		self.albumName.setText("Album: " + self.audioFile["album"][0])
		self.lyrics.setText(PyLyrics.getLyrics(self.audioFile["artist"][0], self.audioFile["title"][0]))
	
if __name__ == "__main__":
	app = QApplication(sys.argv)
	window = MusicPlayer()
	window.show()
	sys.exit(app.exec_())
But never in my code have I used "BeautifulSoup" at all! So I can't change it as suggested by the message...
How can I remove or fix this annoying warning? The program works fine, I just don't like errors in the console.
PyLyrics is the module that uses BeatifulSoup in some way, but I don't know how to get rid of the warning. Help :(

PS: It says that it's caused on line 101, but it's not if you look at that line.

actually you are using BeautifulSoup (indirectly). In your GUI file you are calling the setHtml function of the QTextBrowser item "lyrics". At least that is the only part where it might be called.
The interesting part is, that my system does not show any warning at all.
Since creating the MusicPlayer object does not throw any warning I do not think the problem is in your PyLyrics file. So the setHtml function could be the reason.

But isn't that (setHtml) the only way to make a html window in order to load the text?

Guess I'll need to edit PyLyrics source on every machine I use to remove the warning...
Can i catch user warnings as exceptions btw? That way i won't have to edit every pylyrics module on each pc which runs the app.
You can use the warnings module to treat warnings as exceptions, or you can also just ignore them entirely. Here's some reading for you: https://docs.python.org/3/library/warnin...e-warnings

import warnings
warnings.filterwarnings("ignore", category=UserWarning, module='bs4')
(May-14-2018, 03:42 PM)nilamo Wrote: [ -> ]You can use the warnings module to treat warnings as exceptions, or you can also just ignore them entirely. Here's some reading for you: https://docs.python.org/3/library/warnin...e-warnings

import warnings
warnings.filterwarnings("ignore", category=UserWarning, module='bs4')

Awesome, thanks :)
(May-11-2018, 07:48 AM)ThiefOfTime Wrote: [ -> ]The interesting part is, that my system does not show any warning at all.
Since creating the MusicPlayer object does not throw any warning I do not think the problem is in your PyLyrics file. So the setHtml function could be the reason.
If you installed bs3 then you wont get a warning. Its the newer bs4 that you will.
I have installed bs4 and using python3. no errors so far :)
Pages: 1 2