Python 无法安装 pip:权限被拒绝错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4359870/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Unable to install pip: Permission denied error
提问by Eitan
I am trying to install pip but currently unable to. I navigate to the pip folder and
我正在尝试安装 pip 但目前无法安装。我导航到 pip 文件夹并
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
我也尝试easy_install .并尝试参考相关线程但没有运气:Python install uninstall easy_install
Any ideas?
有任何想法吗?
采纳答案by Peter Rowell
Looks like you're on an Linux/Unix box and you're not root ... which means you don't have permissionto put things in /usr/local/bin(or a lot of other places).
像你看起来是上的Linux / Unix框,你不是根...这意味着你没有权限把一些东西/usr/local/bin(或很多其他的地方)。
Update for comments:
评论更新:
Since OS X is (under the hood) FreeBSD Unix, there is still the basic concept of 'root'. Your admin account is capableof 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 with sudo, 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. sudowill only prompt you the first time (or every N minutes) for a password.
由于 OS X 是(在幕后)FreeBSD Unix,因此仍然存在“root”的基本概念。您的管理员帐户能够执行 root 类型的操作,但它不会自动提升权限(这是一件好事)。您要查找的命令是sudo,它提供临时 root 权限。要为单个命令(最正常的情况)执行此操作,只需在命令前加上sudo,例如sudo python setup.py install。您可能会被提示再次提供您的密码(不是root的密码,而是您自己的密码),然后该命令将被执行。sudo只会在第一次(或每 N 分钟)提示您输入密码。
I noted herethat in 10.5 and later, sudowill only work if your admin account has a password. If it doesn't, then you will have to set one before this will work.
我在这里指出,在 10.5 及更高版本中,sudo只有在您的管理员帐户有密码时才有效。如果没有,那么您必须先设置一个,然后才能工作。
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!
如果您有一大堆需要以 root 身份执行的操作,请尝试sudo /bin/bash(或您选择的 shell),这将为您提供一个具有完全 root 权限的新 shell(作为另一个 shell 的子进程)。注意 好吧:如果您不习惯在 root 提示符下生活,这不是一个好主意。轻轻一按键盘,您就可以将您的系统钉在外屋墙上。所以出门要小心!

