FeatureNotFound:找不到具有您请求的功能的树构建器:lxml。您需要安装解析器库吗?

时间:2019-11-17 07:59:42

标签: python beautifulsoup jupyter-notebook lxml sentiment-analysis

我尝试运行此代码来处理“ teks”。它显示 FeatureNotFound:找不到具有您请求的功能的树构建器:lxml。您需要安装解析器库吗?

def proses_teks(teks):
soup = BeautifulSoup(teks, "lxml") 
souped = soup.get_text()
try:
    teks = souped.decode("utf-8-sig").replace(u"\ufffd", "?")
except:
    teks = souped
teks_bersih= re.sub("[^a-zA-Z0-9]", " ",(re.sub(www_pat, '', re.sub(combined_pat, '', teks)).lower()))
teks_bersih= ' '.join([word for word in teks_bersih.split() if word not in stopword_user])
return (" ".join([x for x in tok.tokenize(teks_bersih) if len(x) > 1])).strip()

 teks='''hahaha apakah SAYA ingin pergi pada tanggal 15 bulan februari besok ? tidak karena
hari kemarin @twitter suka main https://www.twitter.com'''

proses_teks(teks)

错误:

    ---------------------------------------------------------------------------
FeatureNotFound                           Traceback (most recent call last)
<ipython-input-83-334183dacf47> in <module>
----> 1 proses_teks(teks)

<ipython-input-81-598b2eb2c340> in proses_teks(teks)
      1 def proses_teks(teks):
----> 2     soup = BeautifulSoup(teks, "lxml")
      3     souped = soup.get_text()
      4     try:
      5         teks = souped.decode("utf-8-sig").replace(u"\ufffd", "?")

c:\users\blabla\appdata\local\programs\python\python36-32\lib\site-packages\bs4\__init__.py in __init__(self, markup, features, builder, parse_only, from_encoding, exclude_encodings, element_classes, **kwargs)
    214                     "Couldn't find a tree builder with the features you "
    215                     "requested: %s. Do you need to install a parser library?"
--> 216                     % ",".join(features))
    217 
    218         # At this point either we have a TreeBuilder instance in

FeatureNotFound: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library?

我已经读到了一些错误,它说我应该更改

soup = BeautifulSoup(teks, "lxml") 

soup = BeautifulSoup(html, "lxml") 

但是错误再次出现,并说NameError: name 'html' is not defined

我该怎么办?

0 个答案:

没有答案