![OS X Lion easy_install 需要 sudo ...?](https://linux22.com/image/1305394/OS%20X%20Lion%20easy_install%20%E9%9C%80%E8%A6%81%20sudo%20...%EF%BC%9F.png)
我在 OS X Lion 上,想要设置 python 虚拟环境。我想使用 virtualenvwrapper。
有人可以确认正确的方法是通过 easy_install (然后是 pip)安装软件包须藤
语境: 我想使用 pip 来安装 virtaulenv,所以我这样做了
$ 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.
似乎我让 easy_install 工作的唯一方法是使用 sudo。我在其他地方读到过这是一个坏主意(尽管我并不完全确定为什么)。
澄清,
$ which python
/usr/bin/python
版本号是 2.7.1。
答案1
使用以下命令使 /Library/Python/2.7/site-packages/ 可在全球范围内执行:
sudo chmod -R 755 /Library/Python/2.7/site-packages
对我有用。
答案2
在 Lion 之前,/Library/Python
默认情况下是用户可写的(除非您开始使用sudo easy_install
一次,之后新创建的文件不再是用户可写的)。 Lion 改变了这一点,尽管原因尚不清楚。因此,您可以更改所有权/Library/Python
或添加sudo
到所有easy_install
操作。
看自制软件 维基更多细节。
答案3
下载安装工具再次使用此命令进行安装将解决您的问题。
sudo sh setuptools-0.6c11-py2.7.egg --prefix=~ --install-dir=/Library/Python/2.7/site-packages/