我只是想通过pip安装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有一个单独的库和用户文件吗?也就是说,我在用户文件中,不是"拥有"文件的root吗?如果是,这是否意味着我应该使用
sudo chown gaby:staff /Library/Python/2.7/site-packages
这样做安全吗?如果我不在Unix上(我在macos上(,sudo会做任何事情吗?我也很困惑,如果网站软件包文件夹是专门为第三方软件包设计的,为什么我会遇到这个问题。
提前感谢
尝试sudo pip install beautifulsoup4
,或者最好使用virtualenv。您应该能够在不更改上述目录的权限的情况下执行其中任何一项。