Python code is being executed forever when edited outside of Glyphs

Hi, I have this simple code that works just fine when executed from Macro panel, when run from Script folder it takes forever, rainbow umbrella starts spinning and I have to force quit the program. It happens even with one glyph files. I also cannot automacily install addons from preferences window, could it have something to do with?

Thanks Jan

font = Glyphs.font

for glyph in font.glyphs:
        print glyph

Please have a little more patience. The first script that runs in an app session triggers the loading of the extra modules. That takes a few seconds. ALl subsequent script runs can make use of the already loaded modules.

It was like 20 seconds, once it finished execution but the next one took same amount of time. When I copy paste the same code into macro panel and execute it there, it finished as quickly as you blink… where is the difference between running it from a file to running it in glyphs?

There shouldn’t be any, except for the automatic loading of the modules. Perhaps reinstall the modules in Preferences > Addons.

There seems to be a problem with your python environment. Can you make sure that you don’t have a custom python version and that the system python works correctly?

And what system version do you have?

It is freshly bought used mac with Mojave 10.13, I installed latest Glyphs and the only thing I have done was installing few programs and Python 3.7.3. As I have mentioned, I can’t install modules from preferences as well, it says " The modules could not be installed Could not load the modules. "… What could I check, please? Is glyphs using pip for anything? It seems like I have pip for Py -3 but not for -2. Both pip and pip3 commands link to Python 3

– System: 2.7.10 (default, Feb 22 2019, 21:55:15)
[GCC 4.2.1 Compatible Apple LLVM 10.0.1 (clang-1001.0.37.14)]
– OS: posix; (‘Darwin’, ‘jansindl3r.fritz.box’, ‘18.7.0’, ‘Darwin Kernel Version 18.7.0: Thu Jun 20 18:42:21 PDT 2019; root:xnu-4903.270.47~4/RELEASE_X86_64’, ‘x86_64’)
– App CFBundleShortVersionString: 2.6.1
– App CFBundleVersion: 1230
– Vanilla: <module ‘vanilla’ from ‘/Users/jansindler/Library/Application Support/Glyphs/Scripts/vanilla/init.py’>
– System: 2.7.10 (default, Feb 22 2019, 21:55:15)
[GCC 4.2.1 Compatible Apple LLVM 10.0.1 (clang-1001.0.37.14)]
– OS: posix; (‘Darwin’, ‘jansindl3r.fritz.box’, ‘18.7.0’, ‘Darwin Kernel Version 18.7.0: Thu Jun 20 18:42:21 PDT 2019; root:xnu-4903.270.47~4/RELEASE_X86_64’, ‘x86_64’)
– App CFBundleShortVersionString: 2.6.1
– App CFBundleVersion: 1230
– Vanilla: <module ‘vanilla’ from ‘/Users/jansindler/Library/Application Support/Glyphs/Scripts/vanilla/init.py’>

which makes me thinking, I changed name of my computer… I don’t know how this apple thing works but is that possible that something from Glyphs is linked to full path when I had different name? I tried to uninstall Glyphs but it seems I need better tutorial on how to uninstall programs on Mac :slight_smile: user settings are still there. Running it as guest had the same result

It is quit likely that the problem is caused by the python 3 installation.

Can you put this into the macro window and post the result:

import objc
print objc

<module ‘objc’ from ‘/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/objc/init.pyc’>

macro window is the one that works though, I ll try to run it as script and wait few minutes for result

I got the same output as well from a script that is loaded outside of Glyphs. I think it is slower than running it directly in Glyphs, but still acceptable. When I run scripts that handle Glyphs, it gets much worse. Now I am waiting for 5 minutes, and it is still processing it. Please, how could I solve it? Thanks

And the same script in the macro window is fast?

And can you try in a different user please. I have a suspicion it has something to do with your Python setup local to your user.

Hi, I had some issues even when preparing vim on that machine so I reinstalled OS and it works fine… Sorry! Looking forward to start with Glyphs :slight_smile: