frostschutz / Anki-LilyPond

LilyPond integration addon for Anki
5 stars 2 forks source link

error executing lilypond (and fix) #3

Open tunesmith opened 11 years ago

tunesmith commented 11 years ago

The addon doesn't find the default location of the lilypond executable. It just refers to "lilypond" in the line that invokes the command. When I edited the python source to instead say /Applications/LilyPond.app/Contents/Resources/bin/lilypond, it started working. Not sure everyone else would be able to figure that out though.

frostschutz commented 11 years ago

Which OS are you using? I tested it in Windows and Linux. It has to be in the PATH on either OS, so I assume the same will be true for Macs. If you edited the source that's fine, but it's not like I can put /Application/etcetera into the source for everyone as on most systems that is not where LilyPond will be.

tunesmith commented 11 years ago

Correct, I'm using a mac. Mountain Lion.

Yeah, that's actually not a good assumption that it has to be on the PATH on the Mac. On the Mac, lilypond is completely usable without putting it in your shell path. If you don't want to try and derive lilypond's path in the source, then it would probably be a good idea to have the add-on ask for the path, or at least mention in the documentation that the user must have the lilypond executable in their path. I'm not sure most OS X users would come to that conclusion on their own.

Thanks!

On Nov 10, 2012, at 3:27 AM, Andreas Klauer notifications@github.com wrote:

Which OS are you using? I tested it in Windows and Linux. It has to be in the PATH on either OS, so I assume the same will be true for Macs. If you edited the source that's fine, but it's not like I can put /Application/etcetera into the source for everyone as on most systems that is not where LilyPond will be.

— Reply to this email directly or view it on GitHub.

frostschutz commented 11 years ago

Ah, hmmm. I based the LilyPond support on Anki's LaTeX support and I didn't see any special treatment there for Macs. It uses latexCmd = ["latex", ... so I assumed it had to be in the PATH also in order to work.

But when looking at the source again I discovered this:

# add standard tex install location to osx
if isMac:
    os.environ['PATH'] += ":/usr/texbin"

So there is special treatment for Mac in Anki's LaTeX source after all, and it seems I should add the same to the LilyPond addon. Can you test if inserting this code snippet into the plugins (after the other imports) fixes your issue:?

from anki.utils import isMac
if isMac:
    os.environ['PATH'] += ":/Applications/LilyPond.app/Contents/Resources/bin"

Thanks!

(It seems a bit odd to me that one app would be in /usr and the other isn't - is it really correct?)

frostschutz commented 11 years ago

Also regarding "On the Mac, lilypond is completely usable without putting it in your shell path."

http://www.lilypond.org/macos-x.html actually recommends / explains how to add it to the path. Same for http://www.lilypond.org/windows.html - I'll still add the workaround of course (maybe should do the same thing for Windows while I'm at it) but it's not too unusual to have it in your PATH if it's even mentioned on the same page you download the package.

tunesmith commented 11 years ago

It looks like the below snipped works fine on my end. However, on the Mac, the Tex installation is accomplished through a package installation, so it will always be installed in the same directory location (/usr/texbin). Lilypond, in contrast, is something that is dragged to the Applications directory, so it might not always be there. The user might drag it into their /Users//Applications directory instead, or some other location. I think the below will definitely help as it's the most common location they'd drag it to, but if you wanted to be more robust about it it could output a helpful error message that it couldn't find the lilypond executable.

Anyway, I filed the report because I'm trying to help, that's all. :) Putting a note in the documentation could help too (or instead). As for the lilypond os x installation page, it does have a note that says "please ignore these instructions if you are happy with the GUI" so it's probably common that people don't have it in their PATH.

On Nov 10, 2012, at 12:06 PM, Andreas Klauer notifications@github.com wrote:

from anki.utils import isMac if isMac: os.environ['PATH'] += ":/Applications/LilyPond.app/Contents/Resources/bin"

frostschutz commented 11 years ago

Didn't know LilyPond had a GUI (xD), but anyway, people will just have to add it to their PATH then, if it's not in the default location. I'll put the default location into the addon, and the reference to the PATH into the addon description.

Thanks for your feedback

ericoschmitt commented 11 years ago

Hi, i have been thinking in a way of using anki to study music, and your addon finally gave me the answer. But i had exactly this problem. Error executing lilypond. Reading this i realize that its probably installed in another location /Users//Applications. I use windows vista. How do I replace that? Maybe you could mention this in the first read-me, or change the error message to "Error: Couldnt find Lilypond.exe. Specify it's path at . "

I've read it, is it this? lilypondDir = os.path.join(mw.pm.addonFolder(), "lilypond")

and i replace "lilypond" for "C:\Program Files\LilyPond\usr\bin\lilypond-windows.exe" ??????????

i have tried pasting that C:\Program Files\LilyPond\usr\bin\lilypond-windows.exe and also C:\Program Files\LilyPond\usr\bin in different places, but it doesnt work yet!

frostschutz commented 11 years ago

Sorry, didn't get around to updating the addon yet. :blush:

Until then please add it to your path as described here (Running on the Command Line): Windows: http://www.lilypond.org/windows.html Mac: http://www.lilypond.org/macos-x.html

ericoschmitt commented 11 years ago

YEEEEYYY now it works!! I had actually done that, but it had not worked, because there was a space between the last ; and C:.... it was \Shared; C:\Program Files\LilyPond\usr\bin and now \Shared;C:\Program Files\LilyPond\usr\bin

Now i have "only" to learn how to use lilypond properly, and live haply forever.

I dont know if its complicated to fix that, but maybe you could paste those links you have just told me on the error message meanwhile...

Dude.. Thank you SO MUCH for that. Btw, are you musician with programming as a hobby, or programmer who plays music?