Install fonts ttf in python ayuwhere

how install new fonts from cosole

Do you want to use a different font inside the console? Unfortunately, you can't do that on PythonAnywhere. The console isn't a "real" console running on your machine, it's a JavaScript application running in the browser, so it's limited to the fonts we've configured it with.

On the other hand, if you want to use them from somewhere else (say, in an IPython notebook) then there are a number of possibilities -- let me know if that's what you're trying to do and I'll give you details.

Hello, i need install fonts ttf to my web site, how i do?

TTF fonts are not for websites. They are local to each machine. If you need specific fonts for your website, I would suggest googling around for "web fonts"

Hello Glenn,

I would like to also install some new fonts for my PA web application. Specifically, how can I install the font 'Arial' or 'Humor Sans' so it's available to my python application? Please let me know.

I basically want to increase default the list of fonts available to my application, e.g. the list I get when I run fc-list on a console in PA. Thanks!

may I ask what the usecase for this would be?

We've built an application to do display sequence logos, and we'd like to display characters in more fonts than currently available. As an example, please see the following two pictures. Our application uses matplotlib to draw the characters but we more fonts. Thanks

enter image description here


enter image description here

I see. Very cool!

It seems you may be able to put your fonts in ~/.fonts and it will be available?

Hi Conrad,

I just wanted to comment here in here in case it might be helpful in general. Putting a font file in ~/.fonts will make the font appear when fc-list is run (after running fc-cache), but it may still not be available for individual components, e.g. matplotlib. For the case of mpl, I had to update the fontList.json file ~/.cache/matplotlib.

I think the default location for fonts for the linux OS pythonanywhere is running is /usr/share/fonts, but since this is inaccessible to the user, I would guess custom font files would have to configured manually for each component. I believe the default location for fonts isn't ~/.fonts. Please correct me if this is wrong.


The link that conrad posted also suggested that .local/share/fonts may be a possibility.

Correct, but the link also suggested that these paths may depend on the version of the linux OS. I will try the .local path for fonts in the near future and report back if I find something of relevance for PA users.

I'm trying to install a new font, I've tried placing it in all of the locations above, and it still isn't being found.

The particular code I'm trying to run is: font = PIL.ImageFont.truetype(font, font_size)

The error I'm getting is: OSError: cannot open resource

I've tried placing it:

  • In the same directory as the file that's calling the function.
  • In .local/share/fonts
  • In ~/.fonts

The first argument to that constructor is a file path to the font. See