ImportError: cannot import name ‘HTMLParseError‘ from ‘html.parser‘ (/lib/python3.7/html/parser.py)

1.gensim-3.8.1-cp37-cp37m-manylinux1_x86_64

pp3 install gensim-3.8.1-cp37-cp37m-manylinux1_x86_64

2.pymysql

pip3 install PyMySQL-master1.

3.bz2

_bz2.cpython-37m-x86_64-linux-gnu.so,如果下载的是36m,装的是37的python版本,将36改为37。同时将该包移动到python3安装目录的lib/python3.7/lib-dynload即可

4.from bs4 import BeautifulSoup安装

下载地址:https://www.crummy.com/software/BeautifulSoup/bs4/download/4.9/

python3 setup.py install

由于没加路径,运行完上述命令再输入命令

2to3 -w bs4

再次在python3导入from bs4 import BeautifulSoup报错如下:

ImportError: cannot import name 'HTMLParseError' from 'html.parser' (/lib/python3.7/html/parser.py)

解决办法:/lib/python3.7/site-packages/bs4/builder/_init_.py

把下面几行注释掉:

from . import _htmlparser
register_treebuilders_from(_htmlparser)
try:
    from . import _html5lib
    register_treebuilders_from(_html5lib)
except ImportError:
    # They don't have html5lib installed.
    pass
 

你可能感兴趣的:(linux)