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

北城余情 提交于 2020-02-25 06:48:06

问题


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?


回答1:


Total noob here, but I might have stumbled upon a solution for people that have problems reading in their data in spyder after the Catalina update. I had the same problems you describe and got the same file permission errors.

I couldn't resolve the issue, reinstalled several times but didn't work for me. I couldn't use my Utorrent either, and while attempting to solve that problem I came across https://discuss.pixls.us/t/problems-with-darktable-and-mac-osx-catalina-solved-with-dt-2-6-3-1/14400/19 this forum.

Long story short, in the forum people couldn't really resolve the issue, but someone pointed out that if you just run the application from the terminal, it somehow works. I tried to do this with Spyder, and I seem to be able to use the read_csv('file') function again. So try opening the terminal, then type 'spyder' (without '') and press enter. Somehow all issues seem to be resolved. Hope this helps someone.




回答2:


Same problem here. I re-installed Anaconda based on this link and Python is able to access folders where Catalina has added newly restricted security:

Install Anaconda following instructions below:

https://www.anaconda.com/how-to-restore-anaconda-after-macos-catalina-update/

  1. For Anaconda-Jupyter user, you are good to go

  2. For Commandline (Terminal) Python user, you are good to go

  3. For Anaconda-Spyder user, two options as a workaround after installation above:

    • Avoid Mac default setup-folders and relocate files to /Users/[user_name]/.. OR
    • Launch Spyder through Terminal (execute "sudo spyder") under root user

Lastly, changing or reseting folder/file permission does not resolve permission issue. Despite of the security issue under the more restricted security folders, somehow Spyder-Python is able to open .py files in these folders.

Since Jupyter and commandline Python can access these folders, I assume there will be a fix in the future for Anaconda-Spyder.




回答3:


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.




回答4:


My code didn't work at all after Catalina update. The simplest partial solution that I found was to copy all files containing the scripts in a new folder. That works at least to run the codes, but I still dealing with annoying message to allow access to my files.




回答5:


conda update --all in terminal worked for me. It updated everything. I did have to go through the annoying messages for access to my files as well. but after clicking yes a hundred times it was ab



来源:https://stackoverflow.com/questions/58372768/file-permissions-issue-with-python-spyder-anaconda-after-upgrading-mac-to-catali

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!