PermissionError: [Errno 1] Operation not permitted after macOS Catalina Update
Asked Answered
S

14

49

After installing macOS 10.15 Catalina I am getting the following error for simple file and directory operations in Python 3.x: "PermissionError: [Errno 1] Operation not permitted"

Several operations trigger this error including opening an existing file from the cwd using open(...,'rb'), listdir() and getcwd().

After updating to Catalina and finding that Anaconda and Spyder wouldn't open I read about some of the problems. I removed Anaconda and re-installed it in /Users/myname/ using the .sh terminal installer. Conda and Spyder now open but I still can't perform the operations above.

This works:

os.chdir(basedir)

These do not work and throw the error above:

os.getcwd()
Traceback (most recent call last):

  File "<ipython-input-3-a78b1fb2bab9>", line 1, in <module>
    os.getcwd()

PermissionError: [Errno 1] Operation not permitted

os.listdir()
Traceback (most recent call last):

  File "<ipython-input-2-67fdccf289bf>", line 1, in <module>
    os.listdir()

PermissionError: [Errno 1] Operation not permitted

f=open([pre-existing file],'rb')

However, this does NOT throw the error:

f=open('f1.txt','wb')
f.close()
f=open('f1.txt','rb')

I've already tried setting Full Disk Access permissions for Anaconda and Spyder.

Strangulation answered 21/10, 2019 at 4:9 Comment(0)
A
120

Go to System Preference->Security and Privacy.

In the below image, see Label 1

On the left side click on Full Disk Access see Label 2

Now click on bottom left lock icon and enter password to make changes, see Label 3

Now click on + sign button, see Label 4

Browse the terminal app from Application -> Utilities

Now Terminal added with permission.

Done.

steps

Afreet answered 9/12, 2019 at 14:2 Comment(1)
One thing to add is that if you use the terminal inside softwares such as VSCode, then you will have to give this permission to VSCode (or the software you are using)Orgulous
S
12

If you encounter this issue with Workflows / Automator scripts like I did, the following might help:

  1. Open System Preferences -> Security & Privacy -> Privacy
  2. Click the lock in the bottom left and enter your password to allow changes
  3. Under 'Full Disk Access' click the '+' sign
  4. Add Finder (to quickly find it, press CMD + Shift + G and enter /System/Library/CoreServices/Finder.app)

This should make all workflows work (again)!

Spectrograph answered 2/12, 2020 at 10:46 Comment(0)
A
3

Solved:

What I did I create a new folder I call it 'dev' in my user folder and moved all my files & folders in there, then the permission error disappeared.

Hope this will help you as well.

Arletha answered 27/10, 2019 at 16:47 Comment(0)
H
1

I had the same problem and went to the System Preferences and under Security and Privacy > Developer Tools tab, added the Anaconda program under "Allow Apps below to run software locally...." and restarted the anaconda program and it worked.

EDIT: Something else i observed since i tried out this solution was that it only works when i run spyder from the terminal as a bash command.

Hearthstone answered 18/11, 2019 at 9:49 Comment(0)
F
1

To access folder and files.

  1. Go to system preferences
  2. go to security and privacy.
  3. In the privacy tab, select the files and folders in the left dialog. Unlock the make changes and select the terminal.
Forbidding answered 17/6, 2021 at 21:35 Comment(0)
G
1

I was getting this error when using Pathlib.Path.rmdir(). The issue was not permission, even though that was the error I was getting and lead me here, the documentation says the directory should be empty and mine wasn't. I used shutil.rmtree instead and it worked without granting any of the permissions mentioned here.

Gerianne answered 17/2, 2022 at 17:18 Comment(1)
I had the same issue when using os.remove() on a directory with contents, and this worked.Adigranth
E
1

You may add the jupter-kernel (of the env you are using) into Full disk access under Privacy in Security & Privacy.

Screenshots: https://i.sstatic.net/lEDQ3.jpg

Ecospecies answered 6/9, 2022 at 12:29 Comment(0)
C
1

I had similar issues when trying to install packages with pip after an upgrade to macOS Ventura.

Here's the procedure which worked for me on macOS Ventura:

  • Click the Apple icon in the top left corner of the screen

  • Go to System settings...

  • Select Privacy and Security in the menu on the left

  • Scroll down to Developer Tools in the right-hand panel and click on it

  • Toggle the switch next to Terminal

Collector answered 19/11, 2022 at 10:9 Comment(0)
U
0

I had similar problem with PyCharm which was unable to install any packages. Running chown on the file pyvenv.cfg and setting the same user as it was set for that file before solved the problem.

Ullrich answered 21/9, 2020 at 13:13 Comment(0)
C
0

In Full Disk Access section add Intellij or some IDE else would do the trick. For more: https://support.apple.com/en-us/HT210595

Culbert answered 22/10, 2020 at 15:30 Comment(0)
L
0

I encountered this error because I attempted to start the http server in a directory I had deleted.

Logy answered 15/1, 2021 at 1:1 Comment(0)
F
0

I faced the same issue and restarting my Macbook solved it.

Frankly answered 25/2, 2023 at 10:9 Comment(0)
T
0

If you are using Ventura version, you can just enable your terminal like the following screenshot how to enable your terminal

Taxeme answered 15/3, 2023 at 9:12 Comment(1)
While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From ReviewAdaurd
B
0

There are several suggestions here about adding "Full Disk Access" permissions to various applications. In my case it was a python3 script running within a shortcut that was causing the issue. I needed to grant these permissions to python3 itself in the system settings.

None of these other options (Finder, Terminal, etc.) resolved the issue. I do not know what caused this though because I only recently started to see this problem appear when running shortcuts through the menu bar.

Bunin answered 3/6 at 20:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.