美丽的汤4不使用Python 3.4.0
我使用的是Ubuntu 14.04 64位操作系统。
我使用这个命令安装了Beautiful Soup 4 :
sudo apt-get install python-bs4
使用Python 2.7.6 ,我可以bs4
导入bs4
模块。 但是当我使用Python 3.4.0时它向我展示了这个错误。
>>>import bs4 Traceback (most recent call last): File "", line 1, in ImportError: No module named 'bs4'
我也尝试使用pip安装它。
sudo pip install beautifulsoup4
但是它再次与Python 3.4.0无关。
现在我已经卸载了pip并且还卸载了Beautiful Soup 4
sudo apt-get remove python-bs4 sudo apt-get remove python-pip
接下来我应该怎么做才能为Python 2.7.6和Python 3.4.0正确安装Beautiful Soup 4?
在所有当前支持的Ubuntu版本中打开终端并运行:
sudo apt-get install python3-bs4
python3-bs4是Python 3的容错HTML解析器。你可以从中看到有两个不同的包:python-bs4(用于Python 2.x)和python3-bs4(用于Python 3.x),以及防止您感到困惑,还有两种不同的Python集成开发环境:IDLE和IDLE 3来运行它们。