Managing FastAPI Projects with Poetry: A Step-by-Step Guide

I'm currently working with pyannote.audio
version 3.1.1, and for full compatibility, it requires Python 3.10—especially because it was trained with torch==1.13.1
and CUDA 11.7. But by default, Ubuntu 24.04 ships with Python 3.12, and that caused some issues with dependencies.
noble
) only comes with Python 3.12 by default.sudo apt update
, the package simply couldn’t be found—because it isn’t included in the official package repositories.
deadsnakes/ppa
.# Add the Deadsnakes PPA
$ sudo add-apt-repository ppa:deadsnakes/ppa
$ sudo apt update
# Install Python 3.10 and related tools
$ sudo apt install python3.10 python3.10-venv python3.10-dev \
python3.10-distutils python3.10-gdbm python3.10-tk
If you’d rather compile Python 3.10 yourself—say, to get the latest patch like 3.10.14—you can do that too. I tested this approach and it worked well, though it takes more time and effort.
This installs Python 3.10.14 alongside the default Python, so it won’t interfere with your system installation.
$ sudo apt update
$ sudo apt install -y software-properties-common build-essential \
libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev \
wget curl llvm libncursesw5-dev xz-utils tk-dev \
libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev
$ cd /usr/src
$ sudo wget https://www.python.org/ftp/python/3.10.14/Python-3.10.14.tgz
$ sudo tar xvf Python-3.10.14.tgz
$ cd Python-3.10.14
$ sudo ./configure --enable-optimizations
$ sudo make -j$(nproc)
$ sudo make altinstall
After installing Python 3.10, I created a virtual environment to keep my dependencies isolated. This is how I set it up:
# Create a virtual environment with Python 3.10
$ python3.10 -m venv pyannote_env
# Activate the environment
$ source pyannote_env/bin/activate
This way, I could run pyannote.audio
with the exact versions of torch
, transformers
, and other libraries it expects—without affecting my global Python setup.
make altinstall
)I didn’t know that I could install Python 3.10 via apt install
by adding the ppa:deadsnakes/ppa
repository, so I initially built it from source using make altinstall
. Later, I realized it would be harder to manage, so I removed it manually by deleting the files under /usr/local/
.
This does not affect your system’s default Python (e.g., Python 3.12 on Ubuntu 24.04).
# Main binary and config
sudo rm -f /usr/local/bin/python3.10
sudo rm -f /usr/local/bin/python3.10-config
# Standard libraries
sudo rm -rf /usr/local/lib/python3.10
# Header files
sudo rm -rf /usr/local/include/python3.10
# Man pages
sudo rm -rf /usr/local/share/man/man1/python3.10.1
# Extra binaries
sudo rm -f /usr/local/bin/pip3.10
sudo rm -f /usr/local/bin/idle3.10
sudo rm -f /usr/local/bin/2to3-3.10
# Source folder (optional)
sudo rm -rf /usr/src/Python-3.10.14
Comments
Post a Comment