Python - [Errno 13] 权限被拒绝

Python - [Errno 13] Permission denied

我正在尝试在我的 mac 上安装 python 脚本。
当我 运行 $ python setup.py install 我收到以下消息:

running install
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-1668.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:

http://peak.telecommunity.com/EasyInstall.html

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

我该如何解决这个问题?

python setup.py install 写入根文件夹可能会产生 [Errno 13] Permission denied 错误。

你可以试试这个

sudo python setup.py install

但是更好应该

  • 创建虚拟环境
  • 激活它

然后通过

安装
python setup.py install