无法在Ubuntu 20.04上使用pip为Python 3.10安装BeautifulSoup包



我试图安装BeautifulSoup4以学习网络抓取。我使用pip为Python 3.10安装bs4包,但我无法安装它。任何帮助都可以解决以下回溯错误。注意:我使用的是WSL2 Ubuntu 20.04

root@mascot:~# pip install bs4
Traceback (most recent call last):
File "/usr/bin/pip", line 11, in <module>
load_entry_point('pip==20.0.2', 'console_scripts', 'pip')()
File "/usr/lib/python3/dist-packages/pip/_internal/cli/main.py", line 73, in main
command = create_command(cmd_name, isolated=("--isolated" in cmd_args))
File "/usr/lib/python3/dist-packages/pip/_internal/commands/__init__.py", line 96, in create_command
module = importlib.import_module(module_path)
File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/usr/lib/python3/dist-packages/pip/_internal/commands/install.py", line 24, in <module>
from pip._internal.cli.req_command import RequirementCommand
File "/usr/lib/python3/dist-packages/pip/_internal/cli/req_command.py", line 15, in <module>
from pip._internal.index.package_finder import PackageFinder
File "/usr/lib/python3/dist-packages/pip/_internal/index/package_finder.py", line 21, in <module>
from pip._internal.index.collector import parse_links
File "/usr/lib/python3/dist-packages/pip/_internal/index/collector.py", line 12, in <module>
from pip._vendor import html5lib, requests
ImportError: cannot import name 'html5lib' from 'pip._vendor' (/usr/lib/python3/dist-packages/pip/_vendor/__init__.py)

使用pip-install-ebeautifulsoup4而不是bs4-

当前BS4/Beautifulsoup4与Python 3.10不兼容(可能在未来工作(

BS4发布于2021年9月8日https://pypi.org/project/beautifulsoup4/#history

Python3.10 realease in:2021年10月4日https://devguide.python.org/#status-python分支

在BS4更新之前,我认为存在兼容性问题。

在那之前,一切都应该用3.9,所以我会用它。

相关内容

  • 没有找到相关文章

最新更新