【发布时间】:2020-06-29 02:47:22
【问题描述】:
我正在尝试设置 BeautifulSoup4,以便我可以运行以下命令:
from bs4 import BeautifulSoup
但是,当我去安装 BeautifulSoup4 时,我得到以下信息:
Defaulting to user installation because normal site-packages is not writeable.
Requirement already satisfied: beautifulsoup4 in ./Library/Python/2.7/lib/python/site-packages (4.8.2)
Requirement already satisfied: soupsieve>=1.2 in ./Library/Python/2.7/lib/python/site-packages (from beautifulsoup4) (1.9.5)
Requirement already satisfied: backports.functools-lru-cache; python_version < "3" in ./Library/Python/2.7/lib/python/site-packages (from soupsieve>=1.2->beautifulsoup4) (1.6.1)
$ from bs4 import BeautifulSoup4
from: can't read /var/mail/bs4
在 Python3 中运行时出现此错误
Python 3.8.2
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from bs4 import beautifulsoup4
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name 'beautifulsoup4' from 'bs4' (/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/bs4/__init__.py)
我的电脑上同时安装了 Python 3 和 Python 2.7,但不知道如何让它识别 bs4
感谢您的建议!
【问题讨论】:
-
你是如何安装 BeautifullSoup 的?使用 pip 或其他东西?
-
这难道不是安装包和使用不同 Python 安装运行程序的典型问题吗?我建议使用虚拟环境。
-
是的 - 我通过 pip 添加了它
-
这能回答你的问题吗? install beautiful soup using pip
标签: python python-3.x python-2.7 beautifulsoup