gpt4 book ai didi

python - 在 Mac 上安装 Beautifulsoup4 时收到错误消息

转载 作者:行者123 更新时间:2023-12-01 04:21:15 47 4
gpt4 key购买 nike

我使用的是 Mac,当我尝试安装 Beautiful Soup 时,我的终端上收到一条错误消息。我已经安装了 Python 3。

这是我解压 Beautiful Soup zip 文件后所做的事情

$ cd Users/thepredestrian/Desktop/beautifulsoup4-4.4.1

$ python setup.py install

这是出现的错误消息:

Checking .pth file support in /Library/Python/2.7/site-packages/ 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-966.pth'

The installation directory you specified (via --install-dir, --prefix, or the distutils default setting) was:

/Library/Python/2.7/site-packages/

也许您的帐户没有对此目录的写入权限?如果安装目录是系统拥有的目录,您可能需要登录作为管理员或“root”帐户。如果您没有行政管理权访问 native 时,您不妨选择不同的安装目录,最好是在 PYTHONPATH 环境中列出的目录变量。

有关其他选项的信息,您可能希望咨询文档位于:

https://pythonhosted.org/setuptools/easy_install.html

请对您的系统进行适当的更改,然后重试

任何建议表示赞赏!

最佳答案

尝试使用 sudo 安装。

sudo python setup.py install

另一种方法是使用虚拟环境。在虚拟环境中,您可以在本地而不是系统范围内安装依赖项,因此您不需要访问 root 帐户。

pip install virtualenv
virtualenv test
cd test
source bin/activate

第一行安装 virtualenv。第二行创建一个虚拟环境。第三行和第四行激活(启动)virtualenv。您会注意到提示的变化。在 virtualenv 中,您可以安装依赖项(例如 BeautifulSoup)、运行 python 脚本等。完成后,您只需在 shell 中输入 deactivate 即可停用环境。

关于python - 在 Mac 上安装 Beautifulsoup4 时收到错误消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33669417/

47 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com