For Ubuntu 24 I created a virtual environment, installed twine in it, and ran that twine instead of the system package one.