python - 在我不是所有者的文件上使用 sudo chown 是否安全?
问题描述
我只是想 pip install beautifulsoup4 但是这样做我得到这个错误:
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.
所以我这样做是为了检查谁“拥有”该文件,尽管这是我的个人笔记本电脑:
ls -l /Library/Python/2.7/site-packages and it returned this:
-rwxr-xr-x 1 root wheel 157 Oct 7 2017 Extras.pth
-rw-r--r-- 1 root wheel 119 Oct 7 2017 README
-rw-r--r-- 1 root wheel 218 Jul 15 20:20 easy-install.pth
drwxr-xr-x 4 root wheel 128 Jul 15 20:20 pip-10.0.1-py2.7.egg
所以我尝试仅使用以下内容将用户的所有权更改为此目录:
chown gaby:staff /Library/Python/2.7/site-packages
这被退回了:
chown: /Library/Python/2.7/site-packages: Operation not permitted
是因为我是 Macintosh HD 有一个单独的库文件,而用户意味着我,在用户文件中,不是“拥有”文件的根吗?如果是这样,这是否意味着我应该使用
sudo chown gaby:staff /Library/Python/2.7/site-packages
???这是安全的事情吗?如果我不在 Unix 上(我在 mac os 上),sudo 甚至会做任何事情吗?如果 site-packages 文件夹专门用于第三方软件包,我也很困惑为什么我什至会遇到这个问题。
提前致谢
解决方案
尝试sudo pip install beautifulsoup4
或者最好使用virtualenv。您应该能够在不更改上述目录的权限的情况下执行其中任何一项。
推荐阅读
- charts - How can one change the default text in a google visualization controller?
- amazon-web-services - 我的 EC2 配置文件角色在哪里(在 IAM 控制台中)?
- python - python中确保字符串适合作为文件名的优雅方式?
- excel - 根据分值将一列中的值插入新的空白列
- gitlab - gitlab-CI 高效获取 CI 作业的依赖 git 存储库
- javafx - 如何在一个窗口中打开所有舞台?
- python - 参考按下的按钮
- c# - 电子邮件代码验证视图未返回索引页面或确认电子邮件?
- c++ - C++ TCP 套接字 | 无法将 'std::__cxx11::string 转换为 'const char*' | 'server' 未在此范围内声明
- c# - 一旦页面重新提交且输入不完整,上传的文件值将被删除