Skip to content

Instantly share code, notes, and snippets.

@wolfymaster
Created August 5, 2022 03:05
Show Gist options
  • Save wolfymaster/a884e5f184995d41285422cb4f080b22 to your computer and use it in GitHub Desktop.
Save wolfymaster/a884e5f184995d41285422cb4f080b22 to your computer and use it in GitHub Desktop.
Install pyenv
# Install pyenv to manage python versions and create a virtualenv
#!/bin/bash
# clone pyenv repo
git clone https://github.com/pyenv/pyenv.git ~/.pyenv
# Add pyenv to .bashrc
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
# Ask for python version
read -p "python version: " pyversion
PYENV=$(which pyenv)
# Install the python version
bash -c "$PYENV install $pyversion"
# Create virtualenv with python version
virtualenv -p=$(pyenv which python) env
# Start virtualenv
source env/bin/activate
echo "Done"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment