Python issue: Couldn't find a tree builder with the features you requested

I am running security scan via Qark. I am unable to generate html report and I get this error message:

ERROR - failed to write report
Traceback (most recent call last):
  File "/bitrise/src/build/qark/qark/modules/report.py", line 72, in writeSection
    pre_rendered_html2 = BeautifulSoup(pre_rendered, 'html5lib')
  File "/bitrise/src/build/qark/qark/lib/bs4/__init__.py", line 152, in __init__
    % ",".join(features))
FeatureNotFound: Couldn't find a tree builder with the features you requested: html5lib. Do you need to install a parser library?

I tried installing the BeautifulSoup library via pip but still no success. It runs fine on my machine and our previous CI server.

Can it be a python version issue @accolademobile?

From: python - bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library? - Stack Overflow

Assuming you are in OSX, the Apple-bundled version of Python is 2.7.2 which is not lenient for character formatting.

Also:

If doing that sounds like a pain, you can switch over to the LXML parser: …

Seems to be a python / dependency issue.

Another from the same StackOverflow thread:

I preferred built in python html parser, no install no dependencies soup = BeautifulSoup(s, “html.parser”)

From that thread it seems it’s not python version related, and most of the replies mention that

pip install lxml

works / solves the issue.

Thanks, lxml seemed to have solved the issue. At the end of the build however it says report.html could not be generated. I think that might not be true. So, is there a way to view/download the folder so that I can verify the contents of report.html? I can only find .apks in the artifacts section. Remote login process is not that easy either.

Sure! Please see: Build artifacts online - Bitrise Docs

I fixed with with below changes

Before changes
soup = BeautifulSoup(r.content, 'html5lib' )
print (soup.prettify())

After change
soup = BeautifulSoup(r.content, features=“html”)
print(soup.prettify())

my code work properly

2 Likes