'Operation Not Permitted' 在 Mac 终端尝试安装 python 包时

'Operation Not Permitted' on Mac Terminal when trying to install python packages

我正在尝试使用以下代码行在 python 上安装软件包:

git clone https://github.com/dartoon/decomprofile
cd decomprofile
python setup.py develop

一切顺利,直到最后一步,returns错误信息:

error: can't create or remove files in install directory

The following error occurred while trying to add or remove files in the
installation directory:

    [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/test-easy-install-53720.write-test'

The installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:

    /Library/Python/2.7/site-packages/

Perhaps your account does not have write access to this directory?  If the
installation directory is a system-owned directory, you may need to sign in
as the administrator or "root" account.  If you do not have administrative
access to this machine, you may wish to choose a different installation
directory, preferably one that is listed in your PYTHONPATH environment
variable.

For information on other options, you may wish to consult the
documentation at:

  https://setuptools.readthedocs.io/en/latest/easy_install.html

Please make the appropriate changes for your system and try again.

我是我计算机的管理员,所以我不知道为什么我没有更改文件的权限。我也确保我拥有完整的磁盘访问权限。我试过命令

sudo easy_install

但这也不起作用。我在 Mac OS Catalina 在终端应用程序中工作。我最近更新到 anaconda3 并使用 Python 3.8,所以我不确定为什么目录显示 2.7-- 我可以删除这个目录吗?

默认情况下,macOS 预装了 python2.7。 Catalina 还预装了 python3.7。尝试使用 python3 命令代替 python.

您无法删除 python 2.7,因为它是系统依赖项。