Skip to content

Instantly share code, notes, and snippets.

@beyonddream
Last active December 29, 2025 19:18
Show Gist options
  • Select an option

  • Save beyonddream/f706c2ea342b4e2d59f37a80137ffce4 to your computer and use it in GitHub Desktop.

Select an option

Save beyonddream/f706c2ea342b4e2d59f37a80137ffce4 to your computer and use it in GitHub Desktop.
Relatively modern python virtual environment setup

Install direnv

  1. brew install direnv
  2. echo 'eval "$(direnv hook bash)"' >> ~/.bashrc # and restart terminal
  3. direnv version

Installation of Python virtual environment

  1. python3 -m venv .venv # python or python3 should already be installed
  2. echo 'source .venv/bin/activate' > .envrc
  3. direnv allow

Now, whenever you cd to the folder where the virtual environment is setup, it will automatically load the the virtual environment for you.

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