Skip to content

Instantly share code, notes, and snippets.

@gaberogan
Last active February 22, 2022 17:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gaberogan/63e7d7610972a52d8f194e54ee22e80b to your computer and use it in GitHub Desktop.
Save gaberogan/63e7d7610972a52d8f194e54ee22e80b to your computer and use it in GitHub Desktop.
How to install and setup pyenv

Install pyenv + Python

Install pyenv dependencies:

Ubuntu:

sudo apt-get install build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev libffi-dev

MacOS:

brew install openssl readline sqlite3 xz zlib
```## Create Virtual Environments

```bash
pyenv virtualenv VERSION mltest
echo "mltest" > .python-version

Install pyenv: curl https://pyenv.run | bash

Setup terminal integration in ~/.bashrc:

export PATH="$HOME/.pyenv/bin:$PATH"
eval "$(pyenv init --path)"
eval "$(pyenv virtualenv-init -)"

Restart your terminal

Install python (will take some time): pyenv install -v VERSION

The install might fail, so be prepared to troubleshoot

Run this to permanently set default version: pyenv global VERSION

Run python -V and make sure it's the right version

Create Virtual Environments

pyenv virtualenv VERSION mltest
echo "mltest" > .python-version
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment