Rebuilding the python environment#

Summary of responses when rebuilding from python3.8 to python3.13 environment in sphinx+netlify environment

What I want to achieve#

I want to run both the local environment and netlify environment based on python3.13. Currently there is a version mismatch and the netlify side is tied to 3.8.

Operating environment before modification#

Local PC:

Runs on Python3.10, runs on python3.10

netlify:

Works with Ubuntu Focal 20.04, Python3.8

Preparing the local environment#

Uninstalling python3.10#

Delete what was installed in the past by the installer. From now on, it will be unified to Microsoft Store.

PATH error may occur with later pipx or poetry#

Main error details
  • Fatal error in launcher: Unable to create process using ‘C:\Python\Python310\python.exe’

  • No Python at ‘C:\Python\Python310\python.exe’

As a countermeasure, check and delete the following in advance.
  • %HOMEPATH%\APPDATA\Roaming\Python

  • %HOMEPATH%\APPDATA\Local\pipx

  • %HOMEPATH%\APPDATA\Local\poetry

Installing python3.13#

Select and obtain python3.13 from Microsoft Store

pipx maintenance#

pipx maintenance#
python -m pip install --upgrade pip
python -m pip install --user pipx
python -m pipx ensurepath

poetry maintenance#

poetry maintenance#
pipx install poetry

pyproject.toml modified#

Before modification:

python = “^3.10”

After modification:

python = “^3.13”

confirmation#

Build locally and check your site

netlify compatible#

Update the OS image on netlify side#

In the case of Ubuntu Focal 20.04, update the image as it is not compatible with Python3.13.

Setting location:
netlify web management screen
> Site configuration
> Build & deploy settings
> Build image selection
Before modification:

Ubuntu Focal 20.04

After modification:

Ubuntu Noble 24.04

netlify.toml modified#

Reference: How to use configurable Python versions

netlify.toml#
1[build]
2environment = { PYTHON_VERSION = "3.13" }

netlify confirmation#

Run git push. Check the deployment results.

About unifying versions#

Response policy#

Unify the build method to poetry.

Modify requirement.txt#

Before modification:

Pillow==9.5
pydata-sphinx-theme
myst-parser
sphinxcontrib-blockdiag
sphinx-sitemap
sphinxnotes-strike
sphinx-last-updated-by-git
sphinx-git

After modification:

poetry

Modification of netlify.toml#

Before modification:

command = "bash ./build.sh"

After modification:

command = "poetry install --no-root && poetry run poe doc"

Other errors#

blockdiag + Pillow (image drawing)#

Error occurred:

‘FreeTypeFont’ object has no attribute ‘getsize’

background:

Pillow = "==9.5.0" is compatible with Python3.13 and causes an error. I fixed it to Pillow = "^10.0", but blockdiag is not compatible with the latest version of Pillow.

Temporary measures:

We also gave up on maintaining blockdiag as it seemed to have stopped. The usage page has been deleted.

Looking forward:

Exploring the use of graphviz as an alternative

Article information

Post date:

2025-03-23

author:

Mr. Takagi