📌  相关文章
📜  pip install bs4 pip install --trusted-host files.pythonhosted.org --trusted-host pypi.org --trusted-host pypi.python.org - Shell-Bash (1)

📅  最后修改于: 2023-12-03 14:45:30.681000             🧑  作者: Mango

使用pip安装bs4

在Python中,您可以使用 BeautifulSoup 库(简称 bs4)从HTML或XML文件中提取信息。安装该库的最简单方法是使用pip工具。

要安装bs4,打开终端窗口或命令提示符并键入以下命令:

pip install bs4

该命令将从Python Package Index(PyPI)中下载并安装bs4。请确保您的计算机已连接到互联网。

信任主机

如果您在安装过程中遇到以下错误:

Could not fetch URL https://pypi.org/simple/bs4/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/bs4/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping

这表示您的计算机可能无法识别PyPI主机的证书。您可以使用以下命令安装bs4并在该过程中通过信任主机来避免此问题:

pip install bs4 --trusted-host files.pythonhosted.org --trusted-host pypi.org --trusted-host pypi.python.org

这会告诉pip您信任这些主机并允许在这些主机上安装软件包。