Python 尝试在 MAC 上使用 pip 时权限被拒绝?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/50205646/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 19:25:34  来源:igfitidea点击:

Permission denied with trying to use pip on MAC?

pythonmacospython-2.7permissionspip

提问by Sam

Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/beautifulsoup4-4.6.0.dist-info'Consider using the `--user` option or check the permissions.

The error above is the one I get when I try to use the pip command. All I need to do is pip install the requirements.txt to get my program to work. I have python 2.7.1 installed and placed my code where I am able to use python commands. I tried to change permissions by using this command:

上面的错误是我尝试使用 pip 命令时遇到的错误。我需要做的就是 pip install requirements.txt 让我的程序运行。我安装了 python 2.7.1 并将我的代码放在我可以使用 python 命令的地方。我尝试使用以下命令更改权限:

chmod -R 777

but it did not work. I have homebrew installed on my computer. I also tried to use a virtual environment using this link: http://sourabhbajaj.com/mac-setup/Python/virtualenv.htmlbut it gave me permission issues as well. Is there any suggestions to get rid of this permissions issue and run pip successfully? The sudo command below also doesn't work.

但它没有用。我的电脑上安装了自制软件。我还尝试使用以下链接使用虚拟环境:http: //sourabhbajaj.com/mac-setup/Python/virtualenv.html但它也给了我权限问题。是否有任何建议可以摆脱此权限问题并成功运行 pip?下面的 sudo 命令也不起作用。

sudo pip install -r requirements.txt

回答by Aidan Ross

This is a permissions issue.

这是一个权限问题。

Consider using pip install "packagename" --useras mentioned in the error. This is covered HERE

考虑使用pip install "packagename" --user错误中提到的方法。这被涵盖在这里

回答by Beni

try using sudo pip install djangorestframeworkfor Mac. Worked for me.

尝试使用sudo pip install djangorestframeworkMac。为我工作。