在M上安装Beauty Soup4时收到错误消息

2024-04-20 09:23:14 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在使用Mac电脑,当我试图安装Beautiful Soup时,我的终端上收到一条错误消息。我已经安装了python3。在

这是我在打开漂亮的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/

可能您的帐户没有此目录的写入权限?如果 安装目录是系统拥有的目录,您可能需要登录 作为管理员或“根”帐户。如果你没有 访问此计算机时,您可能希望选择不同的安装方式 目录,最好是在PYTHONPATH环境中列出的目录 变量。在

有关其他选项的信息,您可能希望咨询 文件地址:

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

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

有什么建议吗!在


Tags: installor文件in目录消息packages错误
1条回答
网友
1楼 · 发布于 2024-04-20 09:23:14

尝试使用sudo安装。在

sudo python setup.py install

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

pip install virtualenv
virtualenv test
cd test
source bin/activate

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

相关问题 更多 >