我使用以下命令安装了 BeautifulSoup:
sudo easy_install BeautifulSoup4
我收到消息:
Searching for BeautifulSoup4
Best match: beautifulsoup4 4.1.3
Processing beautifulsoup4-4.1.3-py2.6.egg
beautifulsoup4 4.1.3 is already the active version in easy-install.pth
Using /Library/Python/2.6/site-packages/beautifulsoup4-4.1.3-py2.6.egg
Processing dependencies for BeautifulSoup4
Finished processing dependencies for BeautifulSoup4
我正在尝试导入 BeautifulSoup 库。
>>> from BeautifulSoup import BeautifulSoup
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named BeautifulSoup
或者:
>>> from bs4 import BeautifulSoup
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named bs4
我的 Python 版本是:
python --version
Python 2.7.3
编辑
我明白那个:
Using /Library/Python/2.6/site-packages/beautifulsoup4-4.1.3-py2.6.egg
可能意味着 Python 的版本之间存在冲突
我怎样才能注册这个模块?谢谢