I've just adapted the examples provided in https://www.thepythoncode.com/article/generate-images-from-text-stable-diffusion-python#manually-working-with-different-components with a correct version
If you use WSL remember to:
export LD_LIBRARY_PATH=/usr/lib/wsl/lib:$LD_LIBRARY_PATH