A bit of necro bump.
Using venv creates a virtual environment, but for that to be to a specific version of python you first need to use for example pyenv (conda is a "noob friendly" way of doing that) and THEN activate the python module venv.
DO NOT BLINDLY FOLLOW THESE INSTRUCTIONS, THINGS MIGHT BE VERY DIFFERENT ON YOUR SYSTEM AND CAN CAUSE ISSUES FOR YOU!!
Here is how you
can do it on arch (probably not 1 to 1 applicable to steam deck since steamOS is an atomic version of arch but other similar methods are probably
possible but maybe not recommended).
Code:
# first update your system
sudo pacman -Syu
# install pyenv
sudo pacman -S pyenv
# edit .bashrc and/or .zshrc (or your shell config) and add:
export PYENV_ROOT="$HOME/.pyenv"
eval "$(pyenv init -)"
# restart your shell, close the terminal and open a new or just initialize the shell again, for example for bash you can just type:
bash
# list current used python
python --version
# list available python versions that can be installed, scroll with arrows/PgUp/PgDn, press "q" to exit
pyenv install --list | less
# install preferred version, let's use 3.10 as example (will install latest version of 3.10, ie 3.10.19 but you can also specify exactly what version, like 3.10.10)
pyenv install 3.10
# now enter the directory you want the specific python to be used in
cd /path/to/directory
# list used version of python (should show "system (set by /home/<username>/.pyenv/version)")
pyenv version
# show available python versions via pyenv
pyenv versions
# use specific version of python you installed
pyenv local 3.10
# activate venv module in python (the second venv is the directory name you want to use, could be anything but most users prefer venv or a hidden directory .venv)
python -m venv venv
# check your $PATH
echo $PATH
# activate the venv
. ./venv/bin/activate
# check what python version is used
python -version
pyenv version
# now chek your path again and notice it now has the path to the venv in the beginning (/path/to/the/directory/you/installed/in)
echo $PATH
# deactivate python version when done (DO NOT FORGET TO DO THIS or the python version inside the venv will be used!!!)
deactivate
# check $PATH again and notice it is back to what it was before you activated the venv
echo $PATH
I use
You must be registered to see the links
to activate/deactivate automatically when I enter/exit a directory with a venv setup.
I know myself and I WILL forget to deactivate... xD
After a venv is activated, you can use pip to install python packages without risking messing with your systems python, it will get installed to the version you venv:d.
Again,
make sure you understand what you are doing before messing with things like this. It can be done very similar on a debian based system using apt to install.