[英]About python3.6 when I import bs4, it doesn't work
我将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
它还行不通。
怎么解决这个问题,谢谢〜!
您应该升级您的beautifulsoup模块,使其与python 3.6兼容。 从4.4.0开始, BeautifulSoup
与Python 3.5兼容。 以上
pip3 install --upgrade beautifulsoup4
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.