python-3.xpycharmmacos-monterey

Pycharm on macOS: Operation not permitted on listdir() under Pycharm


I'm trying to do an os.listdir() on a server exported directory.

When I run the Python3 program from the shell, it works fine. But when I run it under the Pycharm debugger, I get a PermissionError exception.

The directory is set to "Read and Write" for "everyone". I've also restarted the Pycharm application.

I'm running on macOS Monterey (old hardware).

Any hints?


Solution

  • MacOS has additional per-process access control restrictions beyond filesystem permissions -- this is basically what's at play when it asks you if process X should be able to access your Documents/desktop/etc.

    Go to "Privacy and Security", then "Files and Folders"; find pycharm therein, and make sure "Network Volumes" is enabled.