Python versions not finding Glyphs python version / GlyphsApp / objc

Hey,

when trying to get some scripts to run I am seeing odd issues with Python environments and I am not really sure what is the current “supposed to be” state for G 3.

In the Preferences, I have these — from another thread I gathered there should be a “Glyphs” python version there as well?

When checking the Macro python version and installed modules for that Python I get:

Particularly, there seems to be no “GlyphsApp” module available. As you can see in the above (two up) Macro window screenshot, the path seems to include the G 3 folders though.

Hard to understand what should be used and why it’s failing. Also, my Python environments I use are installed via pyenv. Is there supposed to be Glyph’s own Python version in the preferences? And if so, how do you install packages there? Or if any can be picked, how and where from do you get it to use the GlyphsApp module (which supposedly needs the objc to be already loaded, first)?

confused
-J

Install the Glyphs Python from WindowPlugin ManagerModulesPython. After installing, relaunch Glyphs for the option to appear in preferences. Select it and relaunch Glyphs again to load the new Python. Other Python version might also work, but with the Glyphs version you are on the save side of plugin compatibility.

1 Like

Ah, I see. Thanks.

What’s the point of being able to pick the python versions, if you need to install the Glyphs-python and can only use that one (I mean, … you likely want access to the GlyphsApp module, so any other python versions will always miss that one, no?)?

So with Glyph’s python active, how do I pip install for Glyphs to find those modules? Without hijacking stuff into one of those path folders?

And “wild guesses” like this have failed to install anything:

Johanness-MacBook-Pro-4:Glyph-Filters johannes$ /Users/johannes/Library/Application\ Support/Glyphs\ 3/Repositories/GlyphsPythonPlugin/Python.framework/Versions/3.9/bin/pip install noise

-bash: /Users/johannes/Library/Application Support/Glyphs 3/Repositories/GlyphsPythonPlugin/Python.framework/Versions/3.9/bin/pip: /Library/Frameworks/Python.framework/Versions/3.9/bin/python3.9: bad interpreter: No such file or directory

Johanness-MacBook-Pro-4:Glyph-Filters johannes$ /Users/johannes/Library/Application\ Support/Glyphs\ 3/Repositories/GlyphsPythonPlugin/Python.framework/Versions/3.9/bin/python3 -m install noise

dyld: Library not loaded: /Library/Frameworks/Python.framework/Versions/3.9/Python
  Referenced from: /Users/johannes/Library/Application Support/Glyphs 3/Repositories/GlyphsPythonPlugin/Python.framework/Versions/3.9/bin/python3
  Reason: image not found
Abort trap: 6

You can use your manually installed versions just fine. You just need to install PyobjC:

pip3 install pyobjc

Hm, not sure then what is causing this. Seems to be same python environment (?), but in the macro window objc seems missing. Maybe something to do with the PATH order?

I’m quite sure that Glyphs can’t load a python version inside a .pyenv. So you need to install pyobjc in brew version directly.

Aha.

Okay, so for any other pyenv users:

Find your brew installed python version:

Johanness-MacBook-Pro-4:axi johannes$ brew info python@3.9
python@3.9: stable 3.9.7 (bottled)
Interpreted, interactive, object-oriented programming language
https://www.python.org/
/usr/local/Cellar/python@3.9/3.9.1_6 (3,933 files, 65.4MB)
  Poured from bottle on 2021-02-01 at 14:15:53
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/python@3.9.rb
License: Python-2.0
==> Dependencies
Build: pkg-config ✔...

Then to install directly into the brew python version’s packages which Glyphs will use:

/usr/local/Cellar/python@3.9/3.9.1_6/bin/python3.9 -m pip install whatever

Obviously change your versions as needed.

Also, @GeorgSeifert , this defeats the entire point of having separate pyenv versions if you have to install whatever some script needs into your global python which all pyenv’s inherit from when created, no? I mean, I cannot have several brew python@3.9’s, but only the one I’m messing up now…

There are too many different setups for environments. Glyphs can’t know where to find them.

If your environment contains a Python.framework, you could tell Glyphs about it like this:

Glyphs.defaults["GSPythonFrameworkPath"] = "path/to/folder/containing/framework"