A
A
Anton2021-09-05 17:23:32
Python
Anton, 2021-09-05 17:23:32

Why can't heroku see the ttf file?

When uploading to Heroku Discord, the bot encountered a problem that the script does not see the file (the font, in this case) and refuses to work correctly.
On the locale everything works fine, but on the remote it does not launch functions using the font.

The font in the repository is in .fonts/BAUHS93.ttf, i.e. should not be a problem with detection.
6134d120180a7614484585.png

Error in Heroku logs:
6134d2c6bfaa5945058444.png

What is wrong, please tell me?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vindicar, 2021-09-05
@Vindicar

You are using a relative font path - ".fonts/BAUHS93.ttf".
The relative path is set relative to the current working directory of the program.
Depending on the launch method, it may or may not match the directory where the script is located.
Use sys.argv[0] to get the path to the script and the pathlib module to get the absolute path to the font file instead of relative.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question