Problem running pcbnew python plugin on OS X


There seems to be a permissions problem when running python scripts (e.g. to generate BOM) on OS X

Library not loaded: @executable_path/…/Frameworks/libwx_osx_cocoau_gl-3.0.0.dylib
Referenced from: /Users/geobrown/Kicad/
Reason: unsafe use of @executable_path in /Users/geobrown/Kicad/ with restricted binary

I’m trying to use this tool to generate BOMs

It attempts to load pcb new which causes the error above.

Geoffrey Brown

Make python lib pcbnew global on mac

I’m not familar with Macs, but did you try to start KiCAD as ‘sudo’ or change the permissions on that [quote=“Geoffrey_Brown, post:1, topic:6617”]



It should never be necessary to run Kicad with elevated privileges on OS X.


You are running the script from the Python Scripting Console within pcbnew, right? I would try the script but that would require modifying schematic symbols to add the necessary fields.


I am also running in to exactly the same problem as I am trying to call some python code (which processes a .kicad_pcb file) from a bash script.

The python script runs without error from the console but I want to launch it from a bash script (which, apart from this python problem) otherwise runs normally.

I have tried (partially successfully) as suggested by @wezfurlong to address this by adjusting my PYTHONPATH to /Applications/Kicad/
and then the following works (but not unless I additionally do the sys.path.insert)

~ $ /Applications/Kicad/
Python 2.7.10 (default, Feb  7 2017, 00:08:15)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>import sys
>>>sys.path.insert(0, "/Applications/Kicad/")`
>>>import pcbnew

But this doesn’t seem to work when called from a bash script - I have adjusted the shebang line in my script
(!#/Applications/Kicad/ and included the sys.path.insert.

All being run as unprivileged user - and all relevant scripts have had a chmod a+x on them.

Running out of ideas now - not really a python expert (or a python anything, to be honest!)


Is this anything to do with System Integrity Protection?


I ended up just writing python that read the pcb file directly. It isn’t
really too hard and no need to link to the library and no permission