我正在使用Mac,当我尝试安装Beautiful Soup时,我的终端上收到错误消息。我已经安装了Python 3。
这是我在解开Beautiful Soup zip文件包后所做的事情
$ cd Users/thepredestrian/Desktop/beautifulsoup4-4.4.1
$ python setup.py install
这是出现的错误消息:
检查/Library/Python/2.7/site-packages/中的.pth文件支持 错误:无法在安装目录中创建或删除文件
尝试添加或删除文件时发生以下错误 安装目录:
[Errno 13] Permission denied: '/Library/Python/2.7/site-packages/test-easy-install-966.pth'
您指定的安装目录(通过--install-dir, - prefix, 或distutils默认设置):
/Library/Python/2.7/site-packages/
也许您的帐户没有此目录的写入权限?如果 安装目录是系统拥有的目录,您可能需要登录 作为管理员或“root”帐户。如果你没有行政管理 访问这台机器,您可能希望选择不同的安装 目录,最好是PYTHONPATH环境中列出的目录 变量
有关其他选项的信息,您可以参考 文档:
https://pythonhosted.org/setuptools/easy_install.html
请对您的系统进行适当的更改,然后重试
任何建议表示赞赏!
答案 0 :(得分:2)
Try installing with sudo.
sudo python setup.py install
An alternate way is to use virtual environment. Inside a virtual environment, you can install dependencies locally rather than system wide, so you won't need access to a root account.
pip install virtualenv
virtualenv test
cd test
source bin/activate
The first line installs virtualenv. The second line creates a virtual environment. The third and fourth line activates (starts) the virtualenv. You will notice the change in prompt. Inside virtualenv, you can install dependencies (e.g BeautifulSoup), run python scripts and so on. Once you're done, you can deactivate the environment by simply typing deactivate in the shell.