← Back to Blog
Utility

Managing Python Versions during development

Several time we need to configure our local development environment to our desired Python version. This writing just shows utility commands for doing it.

Install pyenv using brew

brew install pyenv

If it is successfully installed. you can see the version using follwoing command:

pyenv --version

For watching available versions, following command is fine

pyenv versions
  system
  3.8.20
  3.10.7
  3.12.0
* 3.12.8 (set by /Users/abuhaidersiddiq/codes/playground/tutorial-agentic-ai/.python-version)
  3.14.6

For selecting one:

pyenv global 3.14.6

Which Shell you are using can be visible by this:

/bin/zsh

Inject Pyenv Into Your Shell Profile:

If your shell is Zsh (/bin/zsh):

echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.zshrc
echo '[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.zshrc
echo 'eval "$(pyenv init -)"' >> ~/.zshrc

If your shell is Bash (/bin/bash):

echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
echo '[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(pyenv init -)"' >> ~/.bashrc

Reload Your Shell Configuration

# For Zsh users
source ~/.zshrc

# For Bash users
source ~/.bashrc