[GH-ISSUE #4236] Wrong working directory used in webui/routers/utils.py, causing "font not found" when exporting to PDF when installed with pip #29070

Closed
opened 2026-04-25 03:31:51 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @NeilSCGH on GitHub (Jul 31, 2024).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/4236

Bug Report

Description

Bug Summary:
When installed with pip (as described here), the export to PDF doesnt works, because the path to the font ./static/fonts/NotoSans-Regular.ttf uses a relative path with a working directory that depends on where we launch open-webui serve.

Steps to Reproduce:

  • Install open-Webui with pip as described here
  • Start a conversation
  • Download the conversation to PDF

Expected Behavior:
Generate the PDF and download it.

Actual Behavior:
It fail silently in the UI, but with 500 Internal Server Error in the console.

Environment

  • Open WebUI Version: v0.3.10

  • Ollama (if applicable): 0.3.0

  • Operating System: Windows 11

  • Browser (if applicable): Chrome

  • Python Version: 3.11.9

Reproduction Details

Confirmation:

  • I have read and followed all the instructions provided in the README.md.
  • I am on the latest version of both Open WebUI and Ollama.
  • I have included the console logs.

Logs and Screenshots

Console Logs:
Here is the useful part of the log :

INFO:     127.0.0.1:53954 - "POST /api/v1/utils/pdf HTTP/1.1" 500 Internal Server Error
{...}
File "C:\Users\xxxx\.pyenv\pyenv-win\versions\3.11.9\Lib\site-packages\apps\webui\routers\utils.py", line 70, in download_chat_as_pdf
    pdf.add_font("NotoSans", "", f"{FONTS_DIR}/NotoSans-Regular.ttf")
  File "C:\Users\xxxx\.pyenv\pyenv-win\versions\3.11.9\Lib\site-packages\fpdf\fpdf.py", line 1859, in add_font
    raise FileNotFoundError(f"TTF Font file not found: {fname}")
FileNotFoundError: TTF Font file not found: ./static/fonts/NotoSans-Regular.ttf

Installation Method

Installed with pip (as described here

Additional Information

I use pyenv, but that doesn't have an impact here.
Same issue as this discussion.

Note

Open-Webui tries to access NotoSans-Regular.ttf via a relative path ./static/fonts/NotoSans-Regular.ttf, but that . is defined with the working directory from where I've launched open-webui serve, instead of the Lib\site-packages folder.
The issue is in the Lib\site-packages\apps\webui\routers\utils.py file row 67 : STATIC_DIR = "./static".

Proof : Add print("DEBUG: {}".format(os.getcwd())) just after STATIC_DIR = "./static", add an import os at the beginning of the file, restart and try to export. It will show that . is resolved as the directory where I've runned open-webui serve.

The solution would be to use an absolute path, or a relative path based on the python directory.

WORKAROUND for Windows, but should be very similar with linux

  • Open a command prompt
  • Run where python to locate your python folder. Let's say it's C:\Users\USER\AppData\Local\Programs\Python\Python311\python.exe
  • Type cd C:\Users\USER\AppData\Local\Programs\Python\Python311\
  • Type cd Lib\site-packages
  • You're in the right working directory, type open-webui serve
  • Try to export something to PDF
Originally created by @NeilSCGH on GitHub (Jul 31, 2024). Original GitHub issue: https://github.com/open-webui/open-webui/issues/4236 # Bug Report ## Description **Bug Summary:** When installed with pip (as described [here](https://docs.openwebui.com/#installation-with-pip-beta)), the export to PDF doesnt works, because the path to the font `./static/fonts/NotoSans-Regular.ttf` uses a relative path with a working directory that depends on where we launch `open-webui serve`. **Steps to Reproduce:** - Install open-Webui with pip as described [here](https://docs.openwebui.com/#installation-with-pip-beta) - Start a conversation - Download the conversation to PDF **Expected Behavior:** Generate the PDF and download it. **Actual Behavior:** It fail silently in the UI, but with `500 Internal Server Error` in the console. ## Environment - **Open WebUI Version:** v0.3.10 - **Ollama (if applicable):** 0.3.0 - **Operating System:** Windows 11 - **Browser (if applicable):** Chrome - **Python Version:** 3.11.9 ## Reproduction Details **Confirmation:** - [x] I have read and followed all the instructions provided in the README.md. - [x] I am on the latest version of both Open WebUI and Ollama. - [x] I have included the console logs. ## Logs and Screenshots **Console Logs:** Here is the useful part of the log : ``` INFO: 127.0.0.1:53954 - "POST /api/v1/utils/pdf HTTP/1.1" 500 Internal Server Error {...} File "C:\Users\xxxx\.pyenv\pyenv-win\versions\3.11.9\Lib\site-packages\apps\webui\routers\utils.py", line 70, in download_chat_as_pdf pdf.add_font("NotoSans", "", f"{FONTS_DIR}/NotoSans-Regular.ttf") File "C:\Users\xxxx\.pyenv\pyenv-win\versions\3.11.9\Lib\site-packages\fpdf\fpdf.py", line 1859, in add_font raise FileNotFoundError(f"TTF Font file not found: {fname}") FileNotFoundError: TTF Font file not found: ./static/fonts/NotoSans-Regular.ttf ``` ## Installation Method Installed with pip (as described [here](https://docs.openwebui.com/#installation-with-pip-beta) ## Additional Information I use pyenv, but that doesn't have an impact here. Same issue as [this discussion](https://github.com/open-webui/open-webui/discussions/4095). ## Note Open-Webui tries to access `NotoSans-Regular.ttf` via a relative path `./static/fonts/NotoSans-Regular.ttf`, but that `.` is defined with the working directory from where I've launched `open-webui serve`, instead of the `Lib\site-packages` folder. The issue is in the `Lib\site-packages\apps\webui\routers\utils.py` file row 67 : `STATIC_DIR = "./static"`. Proof : Add `print("DEBUG: {}".format(os.getcwd()))` just after `STATIC_DIR = "./static"`, add an `import os` at the beginning of the file, restart and try to export. It will show that `.` is resolved as the directory where I've runned `open-webui serve`. The solution would be to use an absolute path, or a relative path based on the python directory. ## WORKAROUND for Windows, but should be very similar with linux - Open a command prompt - Run `where python` to locate your python folder. Let's say it's `C:\Users\USER\AppData\Local\Programs\Python\Python311\python.exe` - Type `cd C:\Users\USER\AppData\Local\Programs\Python\Python311\` - Type `cd Lib\site-packages` - You're in the right working directory, type `open-webui serve` - Try to export something to PDF
GiteaMirror added the good first issuehelp wanted labels 2026-04-25 03:31:51 -05:00
Author
Owner

@tjbck commented on GitHub (Jul 31, 2024):

PR Welcome!

<!-- gh-comment-id:2260562274 --> @tjbck commented on GitHub (Jul 31, 2024): PR Welcome!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#29070