System permission request for Automation error (PyCharm 2021.1.1, MacOS Catalina)

Dear All,

I have just tried to use the same "xlwings" python lib as in post from 2019, but still doesn't work in 2021. I was googling a debugging for a day (looked for Issue 1146, Issue 1262, Issue 1266)  it works (and asks for the correct permission) in iTerm2, Terminal, but does not work from PyCharm when I'm running the code in Console. I tried also the following command in Terminal:

tccutil reset AppleEvents

as well as I reinstalled PyCharm after a clean uninstall but nothing has changed.

 

Basic run code:

import xlwings as xw

app = xw.Book()

 

The error message is the following:

Traceback (most recent call last):
File "/usr/local/anaconda3/lib/python3.8/site-packages/aeosa/appscript/reference.py", line 482, in __call__
return self.AS_appdata.target().event(self._code, params, atts, codecs=self.AS_appdata).send(timeout, sendflags)
File "/usr/local/anaconda3/lib/python3.8/site-packages/aeosa/aem/aemsend.py", line 92, in send
raise EventError(errornum, errormsg, eventresult)
aem.aemsend.EventError: Command failed: The user has declined permission. (-1743)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/anaconda3/lib/python3.8/site-packages/IPython/core/interactiveshell.py", line 3437, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-2-4bab09758204>", line 1, in <module>
runfile('/Volumes/GoogleDrive/My Drive/Code/Python/python-home-kezdo/test-excel-python-02-xlwings.py', wdir='/Volumes/GoogleDrive/My Drive/Code/Python/python-home-kezdo')
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/_pydev_bundle/pydev_umd.py", line 197, in runfile
pydev_imports.execfile(filename, global_vars, local_vars) # execute the script
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "/Volumes/GoogleDrive/My Drive/Code/Python/python-home-kezdo/test-excel-python-02-xlwings.py", line 6, in <module>
app = xw.Book()
File "/usr/local/anaconda3/lib/python3.8/site-packages/xlwings/main.py", line 557, in __init__
impl = apps.active.books.add().impl
File "/usr/local/anaconda3/lib/python3.8/site-packages/xlwings/main.py", line 3812, in add
return Book(impl=self.impl.add())
File "/usr/local/anaconda3/lib/python3.8/site-packages/xlwings/_xlmac.py", line 203, in add
if self.app.visible:
File "/usr/local/anaconda3/lib/python3.8/site-packages/xlwings/_xlmac.py", line 110, in visible
return appscript.app('System Events').processes[its.unix_id == self.pid].visible.get()[0]
File "/usr/local/anaconda3/lib/python3.8/site-packages/aeosa/appscript/reference.py", line 518, in __call__
raise CommandError(self, (args, kargs), e, self.AS_appdata) from e
appscript.reference.CommandError: Command failed:
OSERROR: -1743
MESSAGE: The user has declined permission.
COMMAND: app('/System/Library/CoreServices/System Events.app').processes[its.unix_id == 80947].visible.get()


I'm using the following configuration:

PyCharm 2021.1.1
Python 3.8.5 (with Anaconda)
xlwings 0.23.0
MacOS 10.15.7 (Catalina)
1 comment
Comment actions Permalink

I would like this to work so I can retrieve (via app script) URLs from Safari

0

Please sign in to leave a comment.