top of page

BeautifulSoup 실행 시 FeatureNotFound 에러 발생

7월 20일
1분 분량

AWS Lambda python3.9에서 다음과 같이 BeautifulSoup 실행 시

soup = BeautifulSoup(response.text, 'lxml')

다음 에러가 발생했을 때의 대처 방법에 대해 비망을 위해 기재합니다.

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

대처1: lxml 설치

에러 메시지에서 lxml의 파서를 설치하면 해결될까 생각해, lxml 라이브러리를 설치

pip install lxml -t .

하지만 현상은 해결되지 않았습니다……

대처2: lxml 대신 html5lib을 쓴다

BeautifulSoup은 파서로서 lxml 외에 html5lib도 지원하므로, html5lib을 사용해 봅니다.

html5lib이 설치되어 있지 않다면 설치를 합니다.

pip install html5lib -t .

BeautifulSoup의 호출 부분을 다음과 같이 수정합니다.

soup = BeautifulSoup(response.text, 'html5lib')

실행해 보니 해결되었습니다.

lxml에 집착할 필요도 없었으므로 저는 이것으로 해결로 삼았습니다.

 
 
 

댓글


© Copyright ROBIN planning LLC.

bottom of page