Skip to content

Instantly share code, notes, and snippets.

@zganger
Created February 4, 2020 15:34
Show Gist options
  • Save zganger/b15ee1a9443ef496a81ad116eefa8649 to your computer and use it in GitHub Desktop.
Save zganger/b15ee1a9443ef496a81ad116eefa8649 to your computer and use it in GitHub Desktop.
Use pyenv with a virtualenv

Using pyenv with virtual environments

Installation:

  • On Mac: brew install pyenv-virtualenv
  • On Linux:
    sudo apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev \
    libreadline-dev libsqlite3-dev llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev
    curl -L https://raw.githubusercontent.com/pyenv/pyenv-installer/master/bin/pyenv-installer | bash
    

Creating a virtualenv:

  • First install the python version you want: pyenv install 3.8.1
  • Create a virtualenv pyenv virtualenv 3.8.1 <venv name>
  • pyenv activate <venv name>
  • pip install any requirements

Uninstalling old versions

  • pyenv uninstall <python version> and confirm each venv and version removal using y
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment