使用Mac OSX管理员帐户安装Beautifulsoup

时间:2012-04-29 23:35:19

标签: python macos installation beautifulsoup easy-install

需要帮助...... 我尝试过多次使用管理员帐户安装beautifulsoup4-4.0.0b3,但是有很多失败。我使用Macpro OS X Lion 10.7.2

终端发生的事情如下:

  

当我小心:easy_install beautifulsoup4

回复:

error: can't create or remove files in install directory 
The following error occurred while trying to add or remove files in 
the installation directory: 
[Errno 13] Permission denied: '/Library/Python/2.7/site-packages/ 
test-easy-install-411.write-test' 
The installation directory you specified (via --install-dir, --prefix, 
or the distutils default setting) was: 
    /Library/Python/2.7/site-packages/ 
Perhaps your account does not have write access to this directory?  If 
the installation directory is a system-owned directory, you may need to 
sign in as the administrator or "root" account.  If you do not have 
administrative access to this machine, you may wish to choose a different 
installation directory, preferably one that is listed in your PYTHONPATH 
environment variable. 
For information on other options, you may wish to consult the 
documentation at: 
  http://peak.telecommunity.com/EasyInstall.html 
Please make the appropriate changes for your system and try again. 

并且它自动重复了这个对话者:

$ easy_install cd beautifulsoup4-4.0.0b3 
error: can't create or remove files in install directory 
The following error occurred while trying to add or remove files in 
the installation directory: 
    [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/ 
test-easy-install-415.write-test' 
The installation directory you specified (via --install-dir, --prefix, 
or the distutils default setting) was: 
    /Library/Python/2.7/site-packages/ 
Perhaps your account does not have write access to this directory?  If 
the installation directory is a system-owned directory, you may need to 
sign in as the administrator or "root" account.  If you do not have 
administrative access to this machine, you may wish to choose a different 
installation directory, preferably one that is listed in your PYTHONPATH 
environment variable. 
For information on other options, you may wish to consult the 
documentation at: 
  http://peak.telecommunity.com/EasyInstall.html 
Please make the appropriate changes for your system and try again. `

这几乎让我发疯。谢谢有人帮我弄明白了 问题是......

2 个答案:

答案 0 :(得分:2)

简单:尝试sudo easy_install beautifulsoup4,然后输入您的管理员密码。

更难:我建议设置一个virtualenv。设置完成后,您可以在没有管理员密码的情况下安装内容。这也是有利的,因为如果你搞砸了Python安装,你可以删除virtualenv并重新开始。 (您确实需要安装XCode才能设置virtualenv,因此它可能有点像哈希尔)

答案 1 :(得分:1)

错误permission denied向您显示您确实拥有写入权限,因此您需要在命令前使用sudo

使用sudo easy_install beautifulsoup4或更好,pip install beautifulsoup4virtualenv,而不必使用sudo