我想重新开始定期使用 Python,特别是用于网页抓取。我使用 Homebrew 安装了 pipenv,并开始安装请求和 BeautifulSoup,但当我尝试导入 BeautifulSoup 时,出现以下错误:
soupsieve package is not installed. CSS selectors cannot be used. 'The soupsieve package is not installed. CSS selectors cannot be used.' Traceback (most recent call last): File "/Users/<user>/.local/share/virtualenvs/virtualenvs-fRlH5dZt/lib/python3.7/site-packages/test.py", line 1, in <module> from bs4 import BeautifulSoup4 File "/Users/<user>/.local/share/virtualenvs/virtualenvs-fRlH5dZt/lib/python3.7/site-packages/bs4/__init__.py", line 34, in <module> from .builder import builder_registry, ParserRejectedMarkup File "/Users/<user>/.local/share/virtualenvs/virtualenvs-fRlH5dZt/lib/python3.7/site-packages/bs4/builder/__init__.py", line 7, in <module> from bs4.element import ( File "/Users/<user>/.local/share/virtualenvs/virtualenvs-fRlH5dZt/lib/python3.7/site-packages/bs4/element.py", line 19, in <module> from bs4.formatter import ( File "/Users/<user>/.local/share/virtualenvs/virtualenvs-fRlH5dZt/lib/python3.7/site-packages/bs4/formatter.py", line 1, in <module> from bs4.dammit import EntitySubstitution File "/Users/<user>/.local/share/virtualenvs/virtualenvs-fRlH5dZt/lib/python3.7/site-packages/bs4/dammit.py", line 13, in <module> from html.entities import codepoint2name ImportError: No module named html.entities [Finished in 0.1s with exit code 1]
有人知道问题是什么吗?html.entities 应该附带 Python3,因此应该可用。