Python Scripts not running. What am I doing wrong?

I’ve been trying to get one of mekkablue’s scripts running, and am having some trouble. Firstly, just double-clicking on it in the Finder, as suggested in the manual, caused it to be opened by Xcode, so I asked for the script to be opened in Glyphs, and I got this error message: “The document “New Tab with Fraction Figure Combos.py” could not be opened. Glyphs cannot open files in the “Python Script” format.”

Opening the Scripts Folder via Glyphs has the same effect.

Before doing this, I did click on the Preferences → Addons → Modules → Install Modules to install Vanilla etc., and got the same lack of confirmation (or notification of error) that someone else did. From the replies to their post, I gather this is normal.

So, what really obvious thing am I missing here?

Scripts are not run with Glyphs, but from Glyphs after you install them in the Glyphs folder which can be found by clicking Scripts/Open Scripts Folder when inside glyphs.

There you will have a Scripts folder in which you have to place the scripts you want to run.

It’s already in there. It won’t run - fires up Xcode instead.

Did you read this tutorial? https://www.glyphsapp.com/tutorials/scripting-glyphs-part-3

As @Realist said, open the Scripts folder and put them there by copying or dragging them from wherever they downloaded to on your system.

Plugins are different from Scripts and are installed by double-clicking them in the Finder; they will be installed automatically into the Plugins folder.

Once they are installed, you run a script by selecting the script name under “Script” in Glyphs on the menu bar. If you do that, it should run. To run plugins you do the same, except they are found listed under “Filter” in the menu bar.

That’s what I’ve been doing. Double-clicking on them in the Finder simply fires up Xcode and does not run the script.

I modified my previous answer slightly to make it more clear.

Where does it say that? I checked again, the handbook explains that plugins can be opened with Glyphs, e.g., by double-clicking, whereas scripts (.py file suffix) must be placed in the Scripts folder and run from the Script menu.

The readmes that accompany my scripts and plugins feature a step-by-step installation guide. If you tell me which parts you did not understand, I could try and improve the wording.

@mekkablue: Your readme seems clear, and I’m sure I’ve done what it says. I have placed the script in the Scripts folder. I cannot spot what to do once the script is there.

@George_Thomas - should it now appear in the Scripts menu? Because it doesn’t. Which is why I’ve been trying various things to get the script to run.

Yes, it should appear in the Scripts menu. Which script in particular are you trying to run?

Hold down the Option key and try Script > Reload Scripts, or restart Glyphs. The scripts will appear in the Script menu. If it does not, can you post a screenshot of your Scripts folder?

Okay, tried that and nothing happened. Glyphs has also been restarted. Here’s a screenshot showing the tiny amount of stuff in my Scripts Folder!

Are you 100% sure that is your Glyphs Scripts folder? Is that a shortcut to it in the sidebar?

Why is New Tab with Fraction Figure Combos 32KB? The original script has a mere 800 bytes.

I suspect that this is not a Python script. How did you download and install the script? Can you open the file in a text editor and post a screenshot?

1 Like

Hooray! It indeed wasn’t. I have fixed it for now by copying and pasting the code from Github in a text editor. How am I supposed to download it from there?

Thanks - it’s working now!

You usually do not download a single script, but the whole repository. On the repository page, e.g., https://github.com/mekkablue/Glyphs-Scripts, there is a button right above the top right corner of the list, called Download ZIP, which puts the complete repository in your Downloads folder. However, I do not recommend that.

If you do want to download just a single script for a single purpose, you can click yourself through to the script, click on the Raw button, and save the source (Cmd-S, choose Save Source) with a .py suffix to your preferred location inside the Scripts folder. However, I do not recommend that either.

What I do recommend is that you sign up at GitHub, download the GitHub app, move it to your Applications folder, run it, set it up with your sign-up credentials, and clone the complete repositories by clicking on the Clone icon:

This opens the repository in the GitHub app. With the GitHub app, it is much easier to stay up to date. All you need to do there, is click on the Sync button every time you need to update.

Repositories change a lot. In mine, there are dozens of little changes (almost) every week. To give you a clue, a large part of my support inquiries for my scripts and plugins are answered with, ‘This is already fixed. Please make sure you have the latest version.’

2 Likes

Thanks.