首页 > 解决方案 > 我无法在 python3 中导入 beautifulsoup

问题描述

当我pip install BeautifulSoup4在命令行中运行时,它会显示这样的输出

已满足要求:/usr/lib/python2.7/dist-packages (4.5.1) 中的 BeautifulSoup4

美汤装在python2.7不在python 3.5

我什至复制和bs4文件BeautifulSoup4夹从仍然导入显示错误是python 2.7/dist-packagespython3.5/distutils/BeautifulSoup4No module named 'Beautiful Soup' found

在运行Beutifulsoup4python2.7,我没有得到相关的输出,因为我在解析 HTML 网页时得到了例外。

请帮助我如何安装bs4python3.5

标签: python-3.xbeautifulsoup

解决方案


使用以下命令安装 BeautifulSoup4:

pip3 install BeautifulSoup4

如果它不起作用,请尝试,

python3 -m pip install BeautifulSoup4

在最坏的情况下,以上都不起作用,请尝试以下命令

apt-get install python3-bs4

或者,对于非 root 用户。

sudo apt-get install python3-bs4


推荐阅读