Install a Custom Python Version
This guide explains how to install your own Python version without root access using pyenv.
1. Clone pyenv:
git clone https://github.com/pyenv/pyenv.git ~/.pyenv
2. Configure your shell:
cat >> ~/.bashrc << 'EOF' export PYENV_ROOT="$HOME/.pyenv" export PATH="$PYENV_ROOT/bin:$PATH" eval "$(pyenv init - bash)" EOF source ~/.bashrc
3. Install your preferred Python version (replace 3.13.5 with any version you need):
pyenv install 3.13.5
4. Set it as your default Python version:
pyenv global 3.13.5
5. Verify the installation:
python --version python3 --version pip --version
Your custom Python installation is now ready to use.
Install Another Python Version
You can install additional Python versions at any time.
Example:
pyenv install 3.12.11 pyenv global 3.12.11
Verify the active version:
python --version
List Installed Versions
pyenv versions
Switch Between Installed Versions
To change the default Python version:
pyenv global 3.13.5
For the current shell only:
pyenv shell 3.13.5
Uninstall a Python Version
To remove a specific Python version:
pyenv uninstall 3.13.5
Remove pyenv Completely
If you no longer need pyenv, remove it with:
rm -rf ~/.pyenv
Then remove the pyenv lines from your ~/.bashrc and reload your shell:
source ~/.bashrc
Notes
- No root access is required.
- You can install multiple Python versions simultaneously.
- Replace 3.13.5 with any Python version supported by pyenv.