As of this writing, when one attempts to run a custom Python3 plugin script for KiCad (v6) where the script file is not located at
/Applications/KiCad/KiCad.app/Contents/SharedSupport/plugins python complains that it cannot find the KiCad libraries.
Apple security boffins have made it all but impossible to set global env variables, so
export PYTHONPATH="..." isn’t really an option, when running plugin scripts from within the KiCad GUI (Generate BOM for example.)
I did get that working by wrapping the text in Command line running the generator: with
sh -c 'export PYTHONPATH="/Applications/KiCad/KiCad.app/Contents/SharedSupport/plugins && [original command here] ' … but then I realized …
Better Way (probably)
In your custom Python script, simply change this …
import kicad_netlist_reader import kicad_utils import csv import sys
… to this …
import sys sys.path.append("/Applications/KiCad/KiCad.app/Contents/SharedSupport/plugins") import kicad_netlist_reader import kicad_utils import csv
I guess KiCad itself may be able to fix this quirk on macOS some day. For now, I’ll stick with what’s working.