- Install required packages
- Set RC
- Install Pyenv
- Install Autoenv
- Install Latest Python
- Set Global Python Version
- Set Vim's Python
- pyenv wiki: Suggested build environment
xcode-select --install
brew install openssl readline sqlite3 xz zlib tcl-tk
build_tools="
build-essential
libssl-dev
zlib1g-dev
libbz2-dev
libreadline-dev
libsqlite3-dev
curl
libncursesw5-dev
xz-utils
tk-dev
libxml2-dev
libxmlsec1-dev
libffi-dev
liblzma-dev
"
sudo apt update
sudo apt install $build_tools
Add to .bashrc
or .zshrc
:
# pyenv
if [ -d "$HOME/.pyenv" ]; then
export PYENV_ROOT="$HOME/.pyenv"
command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
fi
# autoenv
if [ -d "$HOME/.autoenv" ]; then
export AUTOENV_ENV_FILENAME='.autoenv'
export AUTOENV_ENV_LEAVE_FILENAME='.autoenv.leave'
export AUTOENV_ENABLE_LEAVE='enabled'
source "$HOME/.autoenv/activate.sh"
fi
curl https://pyenv.run | bash
git clone https://github.com/hyperupcall/autoenv $HOME/.autoenv
version=3.11
latest_version=$(pyenv latest -k $version)
pyenv install -v --skip-existing $latest_version
global_version=$(pyenv global)
if [ $global_version != $latest_version ]; then
pyenv global $latest_version
fi
pip install --upgrade pip setuptools wheel
pyenv virtualenv $latest_version vim
$HOME/.pyenv/versions/vim/bin/pip install --upgrade pip setuptools wheel pynvim