mirror of
https://github.com/open-webui/open-webui.git
synced 2026-07-17 07:46:16 -05:00
[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
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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.ttfuses a relative path with a working directory that depends on where we launchopen-webui serve.Steps to Reproduce:
Expected Behavior:
Generate the PDF and download it.
Actual Behavior:
It fail silently in the UI, but with
500 Internal Server Errorin 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:
Logs and Screenshots
Console Logs:
Here is the useful part of the log :
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.ttfvia a relative path./static/fonts/NotoSans-Regular.ttf, but that.is defined with the working directory from where I've launchedopen-webui serve, instead of theLib\site-packagesfolder.The issue is in the
Lib\site-packages\apps\webui\routers\utils.pyfile row 67 :STATIC_DIR = "./static".Proof : Add
print("DEBUG: {}".format(os.getcwd()))just afterSTATIC_DIR = "./static", add animport osat the beginning of the file, restart and try to export. It will show that.is resolved as the directory where I've runnedopen-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
where pythonto locate your python folder. Let's say it'sC:\Users\USER\AppData\Local\Programs\Python\Python311\python.execd C:\Users\USER\AppData\Local\Programs\Python\Python311\cd Lib\site-packagesopen-webui serve@tjbck commented on GitHub (Jul 31, 2024):
PR Welcome!