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/", line 482, in __call__
return, params, atts, codecs=self.AS_appdata).send(timeout, sendflags)
File "/usr/local/anaconda3/lib/python3.8/site-packages/aeosa/aem/", 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/", 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/', wdir='/Volumes/GoogleDrive/My Drive/Code/Python/python-home-kezdo')
File "/Applications/", line 197, in runfile
pydev_imports.execfile(filename, global_vars, local_vars) # execute the script
File "/Applications/", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "/Volumes/GoogleDrive/My Drive/Code/Python/python-home-kezdo/", line 6, in <module>
app = xw.Book()
File "/usr/local/anaconda3/lib/python3.8/site-packages/xlwings/", line 557, in __init__
impl =
File "/usr/local/anaconda3/lib/python3.8/site-packages/xlwings/", line 3812, in add
return Book(impl=self.impl.add())
File "/usr/local/anaconda3/lib/python3.8/site-packages/xlwings/", line 203, in add
File "/usr/local/anaconda3/lib/python3.8/site-packages/xlwings/", line 110, in visible
return'System Events').processes[its.unix_id ==].visible.get()[0]
File "/usr/local/anaconda3/lib/python3.8/site-packages/aeosa/appscript/", 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').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)

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


I have the same issue on macOS Monterey and PyCharm 2022.1.3.


Please sign in to leave a comment.