1from PIL import Image
2filename = r'logo.png'
3img = Image.open(filename)
4img.save('logo.ico')
5
6# ====================
7
8# Optionally, you may specify the icon sizes you want:
9
10icon_sizes = [(16,16), (32, 32), (48, 48), (64,64)]
11img.save('logo.ico', sizes=icon_sizes)