You could try pyenv, that allows to use different Python versions for a specific user. I use it for many months now and I'm pretty happy with it.
I'm not sure if this would be allowed by your policies. However, this solution would be something with minimal impact or disruption to your system. You don't have to mangle your system.
Keep in mind, this will only work for a specific user. Other users won't see this change and are not affected. This may or may not be an advantage.
Preparing the system
Before you can use a specific Python version, you need to install and configure pyenv.
Proceed as follows:
Integrate the devel:languages:python:backports repo into your system.
Install the pyenv package:
$ sudo zypper install --details pyenvInstall the following devel packages that are needed to build Python:
$ sudo zypper install -y gcc automake bzip2 libbz2-devel \ xz xz-devel openssl-devel ncurses-devel readline-devel \ zlib-devel tk-devel libffi-devel sqlite3-devel \ gdbm-devel make findutils patchAdd the following lines to your ~/.bashrc file:
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc echo 'eval "$(pyenv init -)"' >> ~/.bashrcIf you use another shell, refer to https://github.com/pyenv/pyenv#set-up-your-shell-environment-for-pyenv
Restart your shell with
exec $SHELLor close your console and open a new one.
Install a different Python version
Your system is ready now. The pyenv command downloads the requested version, compiles it and stores it under ~/.pyenv/versions/. Once this is done, you can use your new Python version in the shell.
To install a specific Python version, proceed as follows:
Install a Python version, for example 3.11:
$ pyenv install 3.11Set this version for your specific user:
$ pyenv global 3.11If you want to restrict it to your current directories, use:
$ pyenv local 3.11Check if
pip3resolves to the local installation:$ pip3.11 --version pip 23.1.2 from /home/tux/.pyenv/versions/3.11.4/lib/python3.11/site-packages/pip (python 3.11)You should see a directory that points to the user, not starting with
/usr/.
After you prepared your systems, pyenv allows you to install any Python library into your local installation. For example:
$ pip3.11 install <LIBRARY>
Closing remarks
Keep in mind, this method circumvents the RPM system and zypper. You don't get any updates from them. However, if you need a newer Python version, you need to update the pyenv package to gain access to the latest versions.
Additionally, you need to be careful about Python version coming from a RPM. You might get confused as there are similar names (pip3.11 vs. pip3-3.11).