Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FileNotFoundError during the imageAutocrop functionality #3

Open
tqmbanados opened this issue Jul 10, 2024 · 1 comment
Open

FileNotFoundError during the imageAutocrop functionality #3

tqmbanados opened this issue Jul 10, 2024 · 1 comment

Comments

@tqmbanados
Copy link

tqmbanados commented Jul 10, 2024

When Maelzel attempts to render the lilypond file, it runs into the following Exception:

Traceback (most recent call last):
  File "...\testing.py", line 24, in <module>
    seq.show()
  File "...\maelzel\core\mobj.py", line 683, in show
    img = self._renderImage(backend=backend, fmt=fmt, scorestruct=scorestruct,
  File "...l\maelzel\core\mobj.py", line 864, in _renderImage
    _renderImage(obj=self, outfile=outfile, backend=backend,
  File "...\maelzel\core\mobj.py", line 1772, in _renderImage
    tmpfile, renderer = _renderImageCached(obj=obj, fmt=fmt, config=config, backend=backend,
  File "...\maelzel\core\mobj.py", line 1798, in _renderImageCached
    renderer.write(outfile)
  File "...\maelzel\scoring\renderlily.py", line 1162, in write
    _imgtools.imagefileAutocrop(tempout, cropfile, bgcolor="#ffffff")
  File "...\maelzel\_imgtools.py", line 45, in imagefileAutocrop
    imgobj = imageAutocrop(imgfile, bgcolor=bgcolor)
  File "...\maelzel\_imgtools.py", line 20, in imageAutocrop
    imgobj = img if isinstance(img, Image.Image) else Image.open(img)
  File "...\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\PIL\Image.py", line 3431, in open
    fp = builtins.open(filename, "rb")
FileNotFoundError: [Errno 2] No such file or directory: '...\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\Local\\tmphgk9m3a_\\ckbcgml5.png'

Fiddling around, I found the filepath sent to PIL.Image is \AppData\Local\tmphgk9m3a_\ckbcgml5.png, which is different from the one called in builtins.open, so its likely changed in the os.path.realpath segment of the `PIL.Image`` file.
I am not familiar enough with how maelzel creates and works with the temp files, or how PIL works to sort this out myself, do you have any recommendations?

@gesellkammer
Copy link
Owner

Could you provide an example to work with?

You seem to be on windows. How did you install maelzel?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants