无法安装 pip:权限被拒绝错误
我正在尝试安装 pip 但目前无法安装。 我导航到 pip 文件夹,
python setup.py install
一切似乎都很顺利,直到最后:
Extracting pip-0.8.2-py2.6.egg to /Library/Python/2.6/site-packages
Adding pip 0.8.2 to easy-install.pth file
Installing pip script to /usr/local/bin
error: /usr/local/bin/pip: Permission denied
我也尝试过 easy_install .
并尝试引用相关线程,但没有成功: Python 安装卸载 easy_install
有什么想法吗?
I am trying to install pip but currently unable to.
I navigate to the pip folder and
python setup.py install
Everything seems to go fine until the very end:
Extracting pip-0.8.2-py2.6.egg to /Library/Python/2.6/site-packages
Adding pip 0.8.2 to easy-install.pth file
Installing pip script to /usr/local/bin
error: /usr/local/bin/pip: Permission denied
I've also tried easy_install .
and attempted to refer to the related thread with no luck: Python install uninstall easy_install
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来您使用的是 Linux/Unix 机器,但您不是 root...这意味着您没有权限将内容放入
/usr/local/bin代码>(或很多其他地方)。
评论更新:
由于 OS X(在底层)是 FreeBSD Unix,因此仍然存在“root”的基本概念。您的管理员帐户能够执行root类型的操作,但它不会自动升级权限(这是一件好事)。您正在查找的命令是 sudo,它提供临时 root 权限。要对单个命令执行此操作(最正常的情况),只需在命令前加上 sudo 前缀,例如 sudo python setup.py install 。系统可能会提示您再次提供密码(不是 root 的密码,而是您自己的密码),然后将执行该命令。
sudo
只会在第一次(或每 N 分钟)提示您输入密码。我此处指出,在 10.5 及更高版本中,
sudo
仅在以下情况下才有效您的管理员帐户有密码。如果没有,那么您必须先设置一个,然后才能起作用。如果您需要以 root 身份做一大堆事情,请尝试 sudo /bin/bash (或您选择的 shell),这将为您提供一个新的 shell(作为其他 shell),具有完全 root 权限。 请注意:如果您不习惯在 root 提示符下生活,这不是一个好主意。只需轻按一下键盘,您就可以将系统钉在室外墙壁上。所以在外面要小心!
Looks like you're on an Linux/Unix box and you're not root ... which means you don't have permission to put things in
/usr/local/bin
(or a lot of other places).Update for comments:
Since OS X is (under the hood) FreeBSD Unix, there is still the basic concept of 'root'. Your admin account is capable of doing root-type things, but it doesn't automatically escalate privileges (which is a Good Thing). The command you are looking for is
sudo
, which provides temporary root privileges. To do it for a single command (the most normal case), simply prefix the command withsudo
, e.g.sudo python setup.py install
. You will probably be prompted to supply your password again (not root's password, but your own) and then the command will be executed.sudo
will only prompt you the first time (or every N minutes) for a password.I noted here that in 10.5 and later,
sudo
will only work if your admin account has a password. If it doesn't, then you will have to set one before this will work.If you have a whole bunch of stuff you need to do as root, try
sudo /bin/bash
(or you shell of choice), which will give you a new shell (as a child process of the other shell) which has full root privileges. Note Well: if you are not use to living at a root-prompt, this is not a great idea. One slip of the keyboard and you can nail your system to the outhouse wall. So be careful out there!