Problem running pcbnew python plugin on OS X


#1

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/kicad.app/Contents/Frameworks/python/site-packages/_pcbnew.so
Reason: unsafe use of @executable_path in /Users/geobrown/Kicad/kicad.app/Contents/Frameworks/python/site-packages/_pcbnew.so with restricted binary

I’m trying to use this tool to generate BOMs https://github.com/kylemanna/kicad-utils

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

Geoffrey Brown


Make python lib pcbnew global on mac
#2

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”]
@executable_path/…/Frameworks/libwx_osx_cocoau_gl-3.0.0.dylib
[/quote]

file?


#3

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


#4

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.


#5

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/kicad.app/Contents/Frameworks/python/site-packages
and then the following works (but not unless I additionally do the sys.path.insert)

~ $ /Applications/Kicad/kicad.app/Contents/Applications/pcbnew.app/Contents/MacOS/Python
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/kicad.app/Contents/Frameworks/python/site-packages")`
>>>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/kicad.app/Contents/Applications/pcbnew.app/Contents/MacOS/Python) 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!)

EDIT

Is this anything to do with System Integrity Protection? https://support.apple.com/en-us/HT204899


#6

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
problems

Geoffrey