Python How to import a module from a parent path for GA?

This is my problem but the solutions don’t work inside Glyphs app—is there a way to do this?

The parent folder of what? Which module? And why do you not simply install the module?

Sorry let me clarify: in the Scripts folder, I have a bunch of scripts that rely on another file, but due to my folder structure some are in a level deeper, so I want to import a script from a parent folder. But the methods in the above that I posted doens’t work?

Adding a folder with sys.path.append doesn’t work, nor does adding files?

Put the file you want to import in the root level of the Scripts folder.

1 Like

I played around with this a bit and this my simples solution:

import os, sys
parentPath = os.path.abspath("..")
if parentPath not in sys.path:
    sys.path.insert(0, parentPath)

from TestModule import TestMethod

TestModule is a python file in the parent folder of the script.

1 Like

This solution still works, but is cumbersome and unintuitive. Is there a more elegant way of importing from a file in a Script folder?

This should be fixed in vanilla now.