Noise module Python 2.7

Hey —

I finally worked out how to install the perlin ‘noise’ module to python 2.7 in the hope that I can access it for Glyphs scripting. I can successfully run a test in python 2.7 via the terminal but it still won’t work in Glyphs. I get a kind of non-error in the macro window.

“Traceback (most recent call last):
File “noise.py”, line 8, in
from noise import *”

Is there something I’m missing with regards to specific versioning or process?

Can you check that the path where you installed is in sys.path as reported inside of Glyphs.

import sys
print sys.path

That spat out a big dump of info about plugins and reporters which refer to python 2.6. Equally however I see a lot of reference to python 2.7 (eg /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7).

Fonttools and Vanilla are in the “/Library/Python/2.7/” so I assumed 2.7 was the right major. There is a 2.6 folder but it’s pretty much empty bar a readme.

sys.version run inside Glyphs is: 2.7.10 (default, Jul 14 2015, 19:46:27)

It recognises the module because if I capitalise it in the import line it says no such one exists.

Sigh.

The plot gets thicker.

I can import noise and successfully run a test in the macro window.

I quit and re-launched, ran that macro test again, then ran a glyphs script with noise functions used and it worked.

I restarted glyphs and ran the glyphs script only and it didn’t.

So long story short it only seems to work if you import noise via the macro first. Totally confusing.

When you see some references to a 2.6 folder, this doesn’t mean that python 2.6 is running, just that your sys.path contains a link to it.

running code in the macro window will change stuff in the python runtime. So you “fix” the import by accident.

1 Like

Can you think of any way around having to do this manually every time? I expect to be using it quite a lot!

Where did you install the noise module? And what is in the macro window?