Setting up Pyenv in .zshrc
~/.zshrc
# Activate Homebrew in the current shell session
eval "$(/opt/homebrew/bin/brew shellenv)"
# Set the PYENV_ROOT variable to point to the location of Pyenv
export PYENV_ROOT="$HOME/.pyenv"
# Check if pyenv command is available, if not, add Pyenv binary directory to PATH
command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"
# Initialize pyenv into the shell session
eval "$(pyenv init -)"
# Initialize pyenv-virtualenv plugin into the shell session
eval "$(pyenv virtualenv-init -)"Setting up pyenv
- Install
pyenvwith Homebrew
brew update
brew install pyenv- Define environment variable
PYENV_ROOTto point to the path wherepyenvwill store its data.$HOME/.pyenvis the default.
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.zshrc- Add the
pyenvexecutable to yourPATHif it's not already there
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.zshrc- Run
eval "$(pyenv init -)"to installpyenvinto your shell as a shell function, enable shims and autocompletion- You may run
eval "$(pyenv init --path)"instead to just enable shims, without shell integration
- You may run
echo 'eval "$(pyenv init -)"' >> ~/.zshrcSetting up pyevn-virtualenv
- Install
pyenv-virtualenvvia Homebrew
$ brew install pyenv-virtualenv- Activate
pyenv-virtualenvin the shell environment by appending the initialization script to the.zshrcfile:
echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.zshrc