PDF Generation - Server Error (FeatureNotFound: Couldn't find a tree builder with the features you requested: html5lib. Do you need to install a parser library?)

Hi, I get this error when i try to generate a pdf of the sales invoice.

Traceback (most recent call last):
File “/home/frappe/frappe-bench/apps/frappe/frappe/app.py”, line 67, in application
response = frappe.api.handle()
File “/home/frappe/frappe-bench/apps/frappe/frappe/api.py”, line 53, in handle
return frappe.handler.handle()
File “/home/frappe/frappe-bench/apps/frappe/frappe/handler.py”, line 22, in handle
data = execute_cmd(cmd)
File “/home/frappe/frappe-bench/apps/frappe/frappe/handler.py”, line 53, in execute_cmd
return frappe.call(method, **frappe.form_dict)
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 939, in call
return fn(*args, **newargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/print_format.py”, line 48, in download_pdf
frappe.local.response.filecontent = get_pdf(html)
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/pdf.py”, line 14, in get_pdf
html, options = prepare_options(html, options)
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/pdf.py”, line 71, in prepare_options
html, html_options = read_options_from_html(html)
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/pdf.py”, line 86, in read_options_from_html
soup = BeautifulSoup(html, “html5lib”)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/bs4/init.py”, line 198, 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?

Facing the same issue while creating any pdf.
Any solution?

Usually, the html5lib directory is available at the following locations

  1. /usr/local/lib/python2.7/dist-packages/pip/_vendor/html5lib

  2. /home/frappe/frappe-bench/env/lib/python2.7/site-packages/pip/_vendor/html5lib

  3. /home/frappe/frappe-bench/env/lib/python2.7/site-packages/html5lib

  4. pwd
    /home/workshop/app_name/frappe-bench

  5. Check for html5lib

ll /home/workshop/app_name/frappe-bench/env/lib/python2.7/site-packages/pip/_vendor/

  1. Check for html5lib

ll /home/workshop/app_name/frappe-bench/env/lib/python2.7/site-packages/

  1. Check for html5lib

if not found

mkdir html5lib

sudo scp -r /home/workshop/app_name/frappe-bench/env/lib/python2.7/site-packages/pip/_vendor/html5lib ./

Then at the end

bench migrate && bench build && bench clear-cache

3 Likes

Thanks…It worked!

Hello, facing same exact problem. solution did not work in my case. please help

Thank you, realized I hadn’t copied the files correctly into the bench py env

2 Likes