inline .show() - recommended install procedure to use ipython / jupyter?

82 views
Skip to first unread message

padovani

unread,
Jan 11, 2021, 6:55:57 AM1/11/21
to abjad...@googlegroups.com
Hello,

I currently have a macOS and a Windows 10 setup running abjad. Both use package tools (brew, for macOS, and chocolatey, for Windows) to install python, abjad, and everything else. I have succeeded to use ipython / jupyter (and also Atom's hydrogen package) to run code in both systems. Nonetheless, I'm not getting to have scores showing inline in jupyter notebooks or in Atom's hydrogen.

Is there a recommended way to install Abjad to have this working? The current docs seem to be still based on 3.0.0 and I'm not sure if I am missing something.

Thanks in advance for any tips!

Trevor Bača

unread,
Jan 11, 2021, 10:40:16 AM1/11/21
to abjad...@googlegroups.com
Hi,

Please take a look at this thread:


Trevor

--
You received this message because you are subscribed to the Google Groups "abjad-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to abjad-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/abjad-user/CA%2BZFxkFkRNBcSUZNidLb7FxUHgj3w-CFJtsu_05S-gxiHhXbmQ%40mail.gmail.com.


--

padovani

unread,
Jan 12, 2021, 7:55:23 AM1/12/21
to abjad...@googlegroups.com
Hi!

Thank you very much!
In windows I got it to work... on macOS (10.13, python 3.8.6, lilypond 2.20.0) I'm having the error below. It seems to be related to the configuration of lilypond (even if it is already in the PATH).

any ideas?

Thank you again!


---------------------------------------------------------------------------
OSError                                   Traceback (most recent call last)
<ipython-input-15-723510008f1a> in <module>
----> 1 abjad.show(staff)

~/abjad/abjad/io.py in show(illustrable, return_timing, **keywords)
    711     """
    712     illustrator = Illustrator(illustrable, **keywords)
--> 713     result = illustrator()
    714     if not result:
    715         return

~/abjad/abjad/io.py in __call__(self)
     81     def __call__(self):
     82         with Timer() as format_timer:
---> 83             string = self.string or self.get_string()
     84         format_time = format_timer.elapsed_time
     85         render_prefix = self.render_prefix or self.get_render_prefix(string)

~/abjad/abjad/io.py in get_string(self)
    157             lilypond_file = self.illustrable.__illustrate__(**self.keywords)
    158         else:
--> 159             lilypond_file = illustrate(self.illustrable, **self.keywords)
    160         return lilypond_file._get_lilypond_format()
    161

~/abjad/abjad/illustrators.py in illustrate(item, **keywords)
    235     if method is None:
    236         raise Exception(f"can not illustrate objects of type {type(item)}.")
--> 237     return method(item, **keywords)
    238
    239

~/abjad/abjad/illustrators.py in _illustrate_component(component)
     23
     24 def _illustrate_component(component):
---> 25     lilypond_file = LilyPondFile.new(component)
     26     return lilypond_file
     27

~/abjad/abjad/lilypondfile.py in new(class_, music, date_time_token, default_paper_size, comments, includes, global_staff_size, lilypond_language_token, lilypond_version_token, tag, use_relative_includes)
   1816         if isinstance(music, LilyPondFile):
   1817             return music
-> 1818         lilypond_file = class_(
   1819             date_time_token=date_time_token,
   1820             default_paper_size=default_paper_size,

~/abjad/abjad/lilypondfile.py in __init__(self, comments, date_time_token, default_paper_size, global_staff_size, includes, items, lilypond_language_token, lilypond_version_token, tag, use_relative_includes)
   1139         self._lilypond_version_token = None
   1140         if lilypond_version_token is not False:
-> 1141             version = LilyPondVersionToken()
   1142             self._lilypond_version_token = version
   1143         if tag is not None:

~/abjad/abjad/lilypondfile.py in __init__(self, version_string)
    877         assert isinstance(version_string, (str, type(None)))
    878         if version_string is None:
--> 879             version_string = configuration.get_lilypond_version_string()
    880         self._version_string = version_string
    881

~/abjad/abjad/configuration.py in get_lilypond_version_string(self)
    477             return self._lilypond_version_string
    478         command = ["lilypond", "--version"]
--> 479         proc = subprocess.run(command, stdout=subprocess.PIPE)
    480         assert proc.stdout is not None
    481         lilypond_version_string = proc.stdout.decode().split()[2]

/usr/local/Cellar/python@3.8/3.8.5/Frameworks/Python.framework/Versions/3.8/lib/python3.8/subprocess.py in run(input, capture_output, timeout, check, *popenargs, **kwargs)
    487         kwargs['stderr'] = PIPE
    488
--> 489     with Popen(*popenargs, **kwargs) as process:
    490         try:
    491             stdout, stderr = process.communicate(input, timeout=timeout)

/usr/local/Cellar/python@3.8/3.8.5/Frameworks/Python.framework/Versions/3.8/lib/python3.8/subprocess.py in __init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, encoding, errors, text)
    852                             encoding=encoding, errors=errors)
    853
--> 854             self._execute_child(args, executable, preexec_fn, close_fds,
    855                                 pass_fds, cwd, env,
    856                                 startupinfo, creationflags, shell,

/usr/local/Cellar/python@3.8/3.8.5/Frameworks/Python.framework/Versions/3.8/lib/python3.8/subprocess.py in _execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, start_new_session)
   1700                     if errno_num != 0:
   1701                         err_msg = os.strerror(errno_num)
-> 1702                     raise child_exception_type(errno_num, err_msg, err_filename)
   1703                 raise child_exception_type(err_msg)
   1704

OSError: [Errno 8] Exec format error: 'lilypond'

Trevor Bača

unread,
Jan 12, 2021, 8:23:19 AM1/12/21
to abjad...@googlegroups.com

Hi,

What do …

~$ lilypond --version
GNU LilyPond 2.21.82

Copyright (c) 1996--2020 by
  Han-Wen Nienhuys <han...@xs4all.nl>
  Jan Nieuwenhuizen <jan...@gnu.org>
  and others.

This program is free software.  It is covered by the GNU General Public
License and you are welcome to change it and/or distribute copies of it
under certain conditions.  Invoke as `lilypond --warranty' for more
information.

… and …

~$ which lilypond
/Applications/LilyPond.app/Contents/Resources/bin/lilypond

… give you at the terminal?

If the shell doesn’t find LilyPond, then add LilyPond to your path.

If the shell finds a stray file called lilypond (that, for example, you have created and put somewhere that your shell finds), then move this file so that your shell finds the legit LilyPond executable somewhere similar to what I’ve pasted in above.

If the shell does find a valid LilyPond executable, what does …

~$ python
Python 3.9.0 (v3.9.0:9cf6752276, Oct  5 2020, 11:29:23) 
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import subprocess
>>> command = ["lilypond", "--version"]
>>> proc = subprocess.run(command, stdout=subprocess.PIPE)
>>> proc.stdout.decode().split()[2]
'2.21.82'

… give you?

When I hide LilyPond from my shell to reproduce your problem, I get …

~$ python
Python 3.9.0 (v3.9.0:9cf6752276, Oct  5 2020, 11:29:23) 
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import subprocess
>>> command = ["lilypond", "--version"]
>>> proc = subprocess.run(command, stdout=subprocess.PIPE)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py", line 501, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py", line 947, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py", line 1819, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'lilypond'

… which is different to what you’re seeing.

The error at the bottom of your stacktrace …

OSError: [Errno 8] Exec format error: 'lilypond'

… is new to me. But Googling makes me think three things:

  1. your shell is in fact finding a file called lilypond; but
  2. that file is either not the real LilyPond executable; or
  3. that file isn’t executable by your user name (which I think is the most likely case).

I’m just guessing, though, based on:

https://stackoverflow.com/questions/27606653/oserror-errno-8-exec-format-error

When you find the solution, please reply back to this thread to archive a solution for later users.


padovani

unread,
Jan 12, 2021, 11:36:29 AM1/12/21
to abjad...@googlegroups.com
Hi!

Just solved here... I had "lilypond" command working from terminal by using lilypond's instruction to create scripts available here: https://lilypond.org/macos-x.html

So, when I've runned "which lilypond", I didn't got the "/Applications/LilyPond.app/Contents/Resources/bin/lilypond" path, but something like "~/bin/lilypond".

To solve it, I've deleted the scripts I had in my "~/bin" dir (as I had, following LilyPond's instructions) and have added the ""/Applications/LilyPond.app/Contents/Resources/bin/" path to my PATH variable in ~/.bash_profile.

Thank you again for the help! :)

Reply all
Reply to author
Forward
0 new messages