Running a KiCad script on MacOS

Greg Davill has made a few awesome KiCad scripts that allow you to export beautiful PCB images:

Unfortunately I’m unable to run them on MacOS. Since python fails to find the pcbnew library:

    Traceback (most recent call last):
  File "", line 9, in <module>
    import pcbnew
ImportError: No module named pcbnew

Doesn’t anybody know how to get this working for KiCad 5.1 on MacOS 10.14.3?

Could you post the full version string? Found via help->about->copy version info
(this info includes the compiler flags used for your build which should give us the information about what is going on.)

Additionally: did your run the script as standalone or using the python console from within pcb_new (or even as an action plugin)?

You may find that you can get what you need if you simply use the Kicad provided Python in the shebang line of your script.


The most consistent way that I have found to run scripts that require pcbnew integration in macOS is to add kicad site-packages directly to your script. So at the top of your script, after the shebang line(s), include something like this;

import sys

Alter the last line if you have a non standard install directory path. Make sure that this comes before

import pcbnew

Needless to say, this kind of kludge shouldn’t be needed. It’s a pity that KiCad’s python support isn’t very good. It doesn’t raise my motivation to learn scripting for KiCad.

Just tried out one of those scripts - the script. With the modifications I suggested this works OK but you also need to change line 314 from ‘inkscape’ to the full inkscape path /Applications/
Symlinking an alias doesn’t work (

Hi @John_Pateman, thanks for your help! It seems your suggestion have solved the issue.

Unfortunately it seems there are still some issues with the script, since the bord edges aren’t respected and the solder-mask layer produces black parts. But I guess that’s a problem with the script, not with the MacOS implementation.

For now, thank you very much for your help! :slight_smile:

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.