PermissionError:[Errno 1] macOS Catalina更新后不允许进行操作 [英] PermissionError: [Errno 1] Operation not permitted after macOS Catalina Update

查看:910
本文介绍了PermissionError:[Errno 1] macOS Catalina更新后不允许进行操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在安装macOS 10.15 Catalina之后,对于Python 3.x中的简单文件和目录操作,我收到以下错误:"PermissionError:[Errno 1]不允许操作"

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"

一些操作会触发此错误,包括使用open(...,'rb'),listdir()和getcwd()从cwd打开现有文件.

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

更新到Catalina后,发现Anaconda和Spyder无法打开,我读到了一些问题.我删除了Anaconda,然后使用.sh终端安装程序将其重新安装在/Users/myname/中. Conda和Spyder现在打开,但是我仍然无法执行上述操作.

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.

这有效:

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')

我已经尝试过为Anaconda和Spyder设置全盘访问"权限.

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

推荐答案

转到系统偏好设置"->安全性和隐私权".

Go to System Preference->Security and Privacy.

现在请看以下图片,请参见标签1

在左侧单击全盘访问",参见标签2

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

现在单击左下角的锁定图标并输入密码进行更改,请参见标签3

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

现在单击+符号按钮,请参见标签4

Now click on + sign button, see Label 4

从Application-> Utilities浏览终端应用程序

Browse the terminal app from Application -> Utilities

现在添加了具有权限的终端.

Now Terminal added with permission.

完成.

这篇关于PermissionError:[Errno 1] macOS Catalina更新后不允许进行操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆