2017-05-24 227 views
-3

導入Beautiful Soup時出現此錯誤。from bs4 import BeautifulSoup Error

from bs4 import BeautifulSoup 
Traceback (most recent call last): 
    File "<pyshell#12>", line 1, in <module> 
    from bs4 import BeautifulSoup 
    File "C:\Users\pood1\AppData\Local\Programs\Python\Python36\lib\site-packages\bs4\__init__.py", line 30, in <module> 
    from .builder import builder_registry, ParserRejectedMarkup 
    File "C:\Users\pood1\AppData\Local\Programs\Python\Python36\lib\site-packages\bs4\builder\__init__.py", line 308, in <module> 
    from . import _htmlparser 
    File "C:\Users\pood1\AppData\Local\Programs\Python\Python36\lib\site- packages\bs4\builder\_htmlparser.py", line 7, in <module> 
    from html.parser import (
ImportError: cannot import name 'HTMLParseError' 
Python:3.6.1 , BeautifulSoup:4-4.3.2 

我該如何解決這個問題?

+0

可能重複的[在Python 3.5中導入bs4](https://stackoverflow.com/questions/28745153/importing-bs4-in-python-3-5 ) –

+0

我解決了這個問題。謝謝。問題是我的Python版本。將版本更改爲3.5.3後,此錯誤消失! –

+0

如果您解決了該問題,請添加解決方案作爲答案並將其標記爲已接受。謝謝。 –

回答

1

你能否升級到美麗湯的最新版本?

pip3 install --upgrade beautifulsoup4 

應該在最新版本中解決這個錯誤。 BeautifulSoup 4.4.0已更新爲python3.5兼容

+0

謝謝。我解決了這個問題。非常感謝你!! –

+0

如果我的回答回答了您的問題,請您接受並投票嗎? – Colwin