Skip to content

Instantly share code, notes, and snippets.

@llipe
Last active November 11, 2024 20:56
Show Gist options
  • Save llipe/0ccdf719e2ba9fc79f5c0b3aa1c82c5b to your computer and use it in GitHub Desktop.
Save llipe/0ccdf719e2ba9fc79f5c0b3aa1c82c5b to your computer and use it in GitHub Desktop.

Python3 Virtualenv Setup

Based on:

Requirements

xcode

xcode-select --install

Homebrew

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)

Installation

To install required components

brew install openssl readline sqlite3 xz zlib tcl-tk pyenv pyenv-virtualenv

Configure zshrc

echo 'export PATH="$HOME/.pyenv/bin:$PATH"' >> ~/.zshrc
echo 'eval "$(pyenv init -)"' >> ~/.zshrc
echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.zshrc
source ~/.zshrc

Check that everything works with pyenv --help

Usage

Install python versions with pyenv install x.y.z. Using pyenv allows you to install multiple version from different vendors. Use pyenv install -l to list all available versions (including regular, anaconda and stackless versions)

Create a virtual environment with pyenv virtualenv 3.9.18 new-venv Activate environment with pyenv activate new-venv and deactivate with pyenv deactivate

Closing notes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment