我進口BS4爲:關於python3.6當我輸入BS4,它不工作
from bs4 import BeautifulSoup
但它拋出一個錯誤是這樣的:
Traceback (most recent call last):
File "/Users/koudai232/Desktop/test.py", line 4, in <module>
from bs4 import BeautifulSoup
File "/usr/local/lib/python3.6/site-packages/bs4/__init__.py", line 30, in <module>
from .builder import builder_registry, ParserRejectedMarkup
File "/usr/local/lib/python3.6/site-packages/bs4/builder/__init__.py", line 308, in <module>
from . import _htmlparser
File "/usr/local/lib/python3.6/site-packages/bs4/builder/_htmlparser.py", line 7, in <module>
from html.parser import (
ImportError: cannot import name 'HTMLParseError'
[Finished in 0.1s with exit code 1]
[cmd: ['/usr/local/bin/python3', '-u', '/Users/koudai232/Desktop/test.py']]
[dir: /Users/koudai232/Desktop]
[path: /usr/bin:/bin:/usr/sbin:/sbin]
但它在python2工作。 7。 更新我的BS4爲:
pip install --upgrade beautifulsoup4
它尚不能工作。
如何解決這個問題,謝謝〜!
檢查此[美湯文檔](https://www.crummy.com/software/BeautifulSoup/bs4/doc/#problems-after-installation) –
嘗試PIP爲Python3:' pip3安裝 - 升級beautifulsoup4' – Dmitry
我通過brew安裝了python3.6,並且找到最新版本的bs4:bs4.5.3,我安裝並替換了以前的版本bs4,但它仍然像之前一樣崩潰。 – Kath