====== Other Python versions and in a notebook (kernel) ======
All command need to be executed in a terminal.\\
List all versions:conda search python
\\
Install your Python version:
mkdir ~/python
export PYTHON_VERSION="3.10"
/opt/miniconda3/bin/conda create --quiet --yes \
--prefix ~/python/"${PYTHON_VERSION}" \
--channel conda-forge \
python="${PYTHON_VERSION}"
Create a virtual environment to be able to add Python packages you need:
mkdir ~/venvs
~/python/${PYTHON_VERSION}/bin/pip install virtualenv
~/python/${PYTHON_VERSION}/bin/virtualenv ~/venvs/my_environment --python ~/python/${PYTHON_VERSION}/bin/python3
source ~/venvs/my_environment/bin/activate
~/venvs/my_environment/bin/pip install ipykernel
Register your new Python version in Jupyter:
~/venvs/my_environment/bin/python -m ipykernel install --prefix /home/jovyan/.local --name py${PYTHON_VERSION} --display-name "Python ${PYTHON_VERSION}"
Source: https://towardsdatascience.com/create-virtual-environment-using-virtualenv-and-add-it-to-jupyter-notebook-6e1bf4e03415
\\
Deactivate the virtualenv:
deactivate
Remove the notebook (kernel):
jupyter kernelspec uninstall py${PYTHON_VERSION}