I think I broke my pyobjc install (and Glyphs is not happy!)

Hi there!

I am relatively new to installing python libraries/modules in OSX, and I believe I have made some error, as Glyphs seems to be upset now.

I was trying to install a library called pywebview, which I believe may have inadvertently messed with the installation of pyobjc? But I can’t be sure.

When I installed plugins that are in the plugin manager, for instance, Glyphs is throwing errors on boot, into the python output window.


For instance with Word-O-Mat installed, upon starting Glyphs I see the error:

Traceback (most recent call last):

  File "main.py", line 10, in <module>


  File "main.py", line 8, in _run

    execfile(path, globals(), globals())

  File "plugin.py", line 17, in <module>

    from GlyphsApp.plugins import *

  File "GlyphsApp/GlyphsApp/plugins.py", line 141, in <module>

TypeError: Error when calling the metaclass bases

    First argument is not an 'objc.informal_protocol' but 'objc.formal_protocol'


Additionally, when I try to write scripts that use the Glyphs.addCallback call from the API, the app crashes. For instance I was adding a callback for DOCUMENTWASSAVED, and upon saving my Glyphs file, the app crashes to desktop instantaneously.

Any idea why this is happening, and what I can do to resolve it?

Thank you!

Attempting to run various scripts I have written for Glyphs, I consistently see the same error:

First argument is not an 'objc.informal_protocol' but 'objc.formal_protocol'

Does this point to a particular way that I may have overwritten or otherwise disturbed some element of my python install?

If you think your pyobjc is broken, you can just try reinstall it :slight_smile:

pip install --upgrade pyobjc

Optionally, first uninstall it:
pip uninstall pyobjc

(You might need to use the --user flag for the install, after --upgrade, if it does not let you install without)

You also might want to consider using a separate python environment for your other development endeavors, to avoid conflicts. Use, for example, virtualenv for that.

Thanks for the recommendation! I was able to make sure pyobjc was upgraded per your instructions, but this doesn’t seem to have solved the issue I’m having. I still see the same error messages within the glyphs macro output window.

I wonder if anyone can shed any light on this informal vs formal objc protocol error?

You might try to remove all custom PyObjC versions as the one from the system should work. The problem you are having was fixed in the code of pyobjc after I reported it a few weeks ago. But the version that comes with macOS shouldn’t have that problem. What version of MacOS do you have?

Georg - I am currently using Catalina (10.15.1). What’s the best way to find out which PyObjC I am running?

Which PyObjC version works, and how do I revert to that one?

Update: As best I can tell, I have installed pyobjc 5.3.

Run this in the macro panel:

import objc

if it says something else than this:

<module 'objc' from '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/objc/__init__.pyc'>

Then the path points to the PyObjC that is currently in use. You should be able to just delete it.

That macro produces this result for me:

<module 'objc' from '/Users/(myusername)/Library/Python/2.7/lib/python/site-packages/objc/__init__.pyc'>

I tried navigating to that path in the finder and then deleting that objc folder.

Now I am receiving this error when I run the same macro you provided:

Traceback (most recent call last):
  File "<macro>", line 4, in <module>
  File "__init__.py", line 9, in <module>
    import Foundation
  File "__init__.py", line 9, in <module>
    import CoreFoundation
  File "__init__.py", line 10, in <module>
    from CoreFoundation import _metadata
ImportError: cannot import name _metadata
<module 'objc' from '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/objc/__init__.pyc'>

Any idea why this would be?

Thank you very much for your help Georg!

what else is in /Users/(myusername)/Library/Python/2.7/lib/python/site-packages/?

I see a large list of folders, presumably all associated with the pywebview install from last night (which seems to have jointly installed all this extra pyobjc stuff I was unaware of).

Should anything installed at that time be erased?

They all have approximately the same time stamp, within a minute or so of each other, when this all began last night.

I would remove all that if you can spare it for the moment. And next time you do stuff link this, use an virtual environment.

Removing these folders seems to have resolved the issue. Thank you very much Georg! I will learn more about virtual environments and avoid this in the future.