MatthiasLienhard / flowkey_dl

helper to create sheet music from flowkey songs
MIT License
70 stars 15 forks source link

OSError: cannot open resource #3

Closed fabiorzfreitas closed 3 years ago

fabiorzfreitas commented 3 years ago

I'm running Python 3.8.6 on Windows 10x64, version 2004 and I'm getting the following error:

C:\Users\Fabio>flowkey-dl
Traceback (most recent call last):
  File "C:\Python38\Scripts\flowkey-dl-script.py", line 33, in <module>
    sys.exit(load_entry_point('flowkey-dl==0.0.1', 'console_scripts', 'flowkey-dl')())
  File "c:\python38\lib\site-packages\flowkey_dl\flowkey_dl_gui.py", line 185, in main
    m=MainWindow(root)
  File "c:\python38\lib\site-packages\flowkey_dl\flowkey_dl_gui.py", line 103, in __init__
    self.prev_img=[ImageTk.PhotoImage(i) for i in arange_image(width=self.prev_width, height=self.prev_height)]
  File "c:\python38\lib\site-packages\flowkey_dl\flowkey_dl.py", line 80, in arange_image
    fnt = [ImageFont.truetype('Pillow/Tests/fonts/FreeMono.ttf', sz) for sz in font_size]
  File "c:\python38\lib\site-packages\flowkey_dl\flowkey_dl.py", line 80, in <listcomp>
    fnt = [ImageFont.truetype('Pillow/Tests/fonts/FreeMono.ttf', sz) for sz in font_size]
  File "c:\python38\lib\site-packages\PIL\ImageFont.py", line 655, in truetype
    return freetype(font)
  File "c:\python38\lib\site-packages\PIL\ImageFont.py", line 652, in freetype
    return FreeTypeFont(font, size, index, encoding, layout_engine)
  File "c:\python38\lib\site-packages\PIL\ImageFont.py", line 193, in __init__
    self.font = core.getfont(
OSError: cannot open resource

I did a fresh reinstall of Python for this and these are the packages I currently have:

Package    Version
---------- ---------
certifi    2020.6.20
chardet    3.0.4
flowkey-dl 0.0.1
idna       2.10
imageio    2.9.0
numpy      1.19.2
Pillow     7.2.0
pip        20.2.1
requests   2.24.0
setuptools 49.2.1
urllib3    1.25.10
MatthiasLienhard commented 3 years ago

I see, this seems to be related to windows not finding the font. If you want to fix that go ahead, I don't have windows here to test, but if I find the time I'll look up how its done properly. https://github.com/MatthiasLienhard/flowkey_dl/blob/f23754d4c114120c93456d5eea51166a550d5068/flowkey_dl/flowkey_dl.py#L80

MatthiasLienhard commented 3 years ago

I removed the path, and it still seems to work on Ubuntu, maybe it works on windows now. https://github.com/MatthiasLienhard/flowkey_dl/blob/a58e26794ecf9bc4b49105b4b7f81473e25a2656/flowkey_dl/flowkey_dl.py#L80

MatthiasLienhard commented 3 years ago

I assume its working

fabiorzfreitas commented 3 years ago

I'm sorry, I never got to test the fix and in meantime I now don't have a flowkey subscription anymore.

Nevertheless, this may help you: I looked into my system folders and they didn't seem to have FreeMono amongst the fonts. Downloading it from somewhere else and properly installing seemed to solve part of my problems, but it all ended up failing somewhere else (in the download process).

Thank you for your support!