Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

File permissions issue with python/Spyder/Anaconda after upgrading mac to Catalina

After upgrading macOS to Catalina, my Anaconda installation was helpfully reconfigured by Apple. Advice from the Anaconda website suggested a fresh install was the best way to go. Did that and all seemed good. I use spyder from the Anaconda navigator. But trying a previously running python code failed due to apparent file permission problems. For example,

file='/Users/stingay/Documents/Coaching/WAIS/2019:20/041019/Race Walk Test-2019-10-04T16.29.13.774-C5612E80FB1D-Accelerometer.csv'

with open(file,'rt') as f:

data = csv.reader(f)
next(data)

results in:

PermissionError: [Errno 1] Operation not permitted: '/Users/stingay/Documents/Coaching/WAIS/2019:20/041019/Race Walk Test-2019-10-04T16.29.13.774-C5612E80FB1D-Accelerometer.csv'

I can't see an issue with the permissions on the file or the directory structure in which the file sits. If I move the file to~/.spyder-py3 (the working directory), it works.

Looks like there is some extra python/spyder/anaconda permissions issue with the file/directory I can't spot. Any ideas?

like image 746
Steven Tingay Avatar asked Oct 14 '19 08:10

Steven Tingay


1 Answers

I guess you have solved this by now, but for future reference, I still post my answer.

TLDR: I opened a file (from the folder causing the problem) directly in the spyder editor (File | open). As a consequence, the editor should have triggered the pop-up dialog question whether you want to allow access or not. In my case, the mac silently granted python/spyder access to the folder. Now I can run the code in spyder without more problems than I have caused myself.

Longer version: The source of your problem is described here: https://www.howtogeek.com/443611/how-macos-catalinas-new-security-features-work/ Knowing that links are something frown upon, here's a summary: The problem is that the folders "Documents" and "Downloads" folders nowadays are protected and you would need to go to the security & privacy settings and "Files and Folder,s" and allow the applications to access these. Unfortunately, spyder does not show up here. So, if you want to run your python program from the terminal, you should probably grant the terminal access to the folders.

like image 114
Daniel Flemström Avatar answered Sep 22 '22 00:09

Daniel Flemström