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

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

问题描述

安装 macOS 10.15 Catalina 后,我在 Python 3.x 中进行简单的文件和目录操作时出现以下错误:PermissionError: [Errno 1] Operation not allowed"

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

在左侧点击 Full Disk Access,见标签 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

从应用程序浏览终端应用程序 -> 实用工具

Browse the terminal app from Application -> Utilities

现在终端已获得许可.

完成.

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

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