OS X Lion easy_install 需要 sudo ...?

w--*_*w-- 7 python easy-install pip osx-lion

我在 OS X Lion 上,想设置 python 虚拟环境。我想使用 virtualenvwrapper。

有人可以确认正确的方法是通过easy_install(以及随后的pip)安装软件包使用sudo

上下文: 安装 virtaulenv 我想使用 pip,所以我做了

$ easy_install pip
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-876.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.
Run Code Online (Sandbox Code Playgroud)

似乎我可以让 easy_install 工作的唯一方法是使用 sudo 来完成。我在别处读到这是一个坏主意(虽然我不完全确定为什么)。

澄清,

$ which python
/usr/bin/python
Run Code Online (Sandbox Code Playgroud)

它是 2.7.1。

Deb*_*ski 1

在 Lion 之前,/Library/Python默认情况下用户可写(除非您开始使用sudo easy_install一次,之后新创建的文件将不再是用户可写的)。Lion 的情况发生了变化,但原因尚不清楚。因此,您可以更改所有操作的所有权/Library/Python或添加sudo到所有easy_install操作。

有关更多详细信息,请参阅自制 wiki 。