Python Subprocess Permissions Error on Mac OS (-1743)?

Hi all,

I am having some trouble with a Permissions Error on Mac OS that wonder if anyone might know the solution to?


Scenario:

From within Grasshopper I am using subprocess to call out to a 3rd party python3 interpreter (doing some read/write using XLWings). This all works just fine on my Windows OS and it is able to open, read, write to active Excel docs as expected:

so that part is fine.


But, when I run the exact same code on the Mac OS side, I get a Permissions Error of some sort:

and I am not able to connect to Excel?

Note: On both Windows and MacOS I am able to successfully call to this subprocess just fine from within Terminal and/or VSCode. It is only when I try and call it ‘through’ Grasshopper that I get this Permissions Error:

OSERROR: -1743
MESSAGE: The user has declined permission.
COMMAND: app(pid=16399).count(each=k.workbook)

So: I wonder if anyone might have encountered / resolved a similar issue, or might know where to look for some solutions to this?

Environment:

  • Macbook 2021, Apple M1 Max
  • OS 12.3 (Monterey)
  • Rhino Version 7 (7.18.22124.03002, 2022-05-04)

thanks for any suggestions or thoughts!
@ed.p.may

Just a little additional info, in case anyone might have any thoughts?

on Mac OS, using subprocess to talk to Excel using XLWings can work, if you run Rhino in sudo

in that case, when I call out to a subprocess or shell script, that connection to Excel is allowed and I do not get the same permission error. I do have to enter my password though, and Rhino boots without any preferences loaded (colors, etc…). But it does work in that case:

so… does anyone know what that might mean? Is there a more ‘normal’ way to give Rhino elevated permissions without running it in terminal / sudo each time? Obviously that method doesn’t work for everyday usage or for distribution to other users…

thanks!
@ed.p.may

rather than give rhino root privileges, you might try giving your user more permissions on the directory where the library is trying to read/write, but this is just a guess, since I can’t test it (seems the permission being denied may have to do with automation, not file access)

you also might try seeing what happens if you start rhino from terminal without sudo, and possibly resetting a perhaps previously-declined permission, as described here before doing so

there are quite a few ideas like these in responses to these posts:

Hi @jdhill

Thanks for the suggestion and the links. And yes I think you are correct, it seems to be a permissions issue on the Rhino side, not the write-file side. I think I have narrowed it down to an issue with the ‘appscript’ call which is what XLWings uses for Excel read/write on the Mac OS side (it uses win32com on the windows side).

So it seems to be an issue of Rhino or GH not being allowed to call its appscript ‘System Events’ level commands like the one here: link?

thanks for the suggestions though!
best
@ed.p.may

Hi @ed.p.may

First off thanks for your hard work building the HB-PH tools!

I was able to get the HB-PH Write PHPP component in on run on Mac by running rhino from the Terminal but without using sudo. In activity monitor Rhino is running under my user instead of root and I got a system prompt when I first ran the Write PHPP component to give permission to rhino to control excel. When launched from the app icon it never shows the prompt and assumes the permission was denied.

This feels like a Rhino issue not handling the system prompt permission request correctly when launched from the GUI vs terminal. Running it sudo didn’t give me the prompt at all since root permissions are already high enough.

As long as I launch rhino from terminal, it remembers this permission, I tried going back to GUI launch after granting it but got the same error code as before unfortunately. Hope this helps in troubleshooting because the other components appear to be working fine so far.

Tangential question, when you run rhino from parallels to avoid this are you on an ARM based Mac, or an Intel? That will be my backup option if I run into more issues on this.

Thank you!
@SColasanti

Hi @SColasanti

Thanks - I am glad you find the HB-Tools useful.

And yes I think you are correct: it appears to be a Rhino for Mac error (or maybe not so much an ‘error’ as an unsupported feature?)

But yes: My current working environment is:

  • MacBook Pro M1 Max (ARM) 2021
  • Monterey v12.5.1 (21G83)
  • Parallels v18.1.1 (53328)
  • Windows 11 (OS Build 22000.1455)
  • Rhino (for windows) 7.25.22326.19001, 2022-11-22

That configuration seems to work as expected and does not give any permissions errors when calling subprocess from within Rhino/Grasshopper.

hope that helps!
best
@ed.p.may