DEV Community

Cover image for How to install Homebrew, Pyenv, Pipenv in WSL (Windows) Ubuntu 20.04
Gokul Y
Gokul Y

Posted on

How to install Homebrew, Pyenv, Pipenv in WSL (Windows) Ubuntu 20.04

Why homebrew? :

Homebrew Installation :

  • Follow the steps mentioned in the below script
$/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Enter fullscreen mode Exit fullscreen mode

output and follow next steps :

image

install homebrew dependencies for Ubuntu (If needed) :

$sudo apt-get install build-essential procps curl file git
Enter fullscreen mode Exit fullscreen mode

Test installation by running below command:

$brew install hello
Enter fullscreen mode Exit fullscreen mode

Pyenv installation

Why pyenv ? :

  • pyenv lets you to switch between python versions in ubuntu.

Install python build dependencies for ubuntu :

$sudo apt-get update; sudo apt-get install make build-essential libssl-dev zlib1g-dev \
libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm \
libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev

Enter fullscreen mode Exit fullscreen mode

then run

$curl https://pyenv.run | bash

Enter fullscreen mode Exit fullscreen mode

Below lines should be available in .bashrc

export PATH="$HOME/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
Enter fullscreen mode Exit fullscreen mode

Restart Shell (If needed) :

$exec $SHELL
Enter fullscreen mode Exit fullscreen mode

or

Run below in windows command prompt :


wsl --shutdown 
& login into ubuntu again

Enter fullscreen mode Exit fullscreen mode

PIPENV Installation

Why pipenv? :

  • pipenv is used to create virtual environment, similar to venv,virtualenv,conda,etc.

Install pipenv using homebrew :

$brew install pipenv

Enter fullscreen mode Exit fullscreen mode

output:
image


References :

  1. https://brew.sh/
  2. https://docs.brew.sh/Homebrew-on-Linux
  3. https://github.com/pyenv/pyenv/wiki#suggested-build-environment
  4. https://github.com/pyenv/pyenv-installer
  5. https://pipenv.pypa.io/en/latest/
  6. Cover Photo by Hitesh Choudhary on Unsplash

Top comments (1)

Collapse
 
joevdotme profile image
Joseph Violago •

Thanks for the post! You helped me catch my mistake in not installing my apt-get dependencies.

You should also mention the step to add brew to ~/.profile/~/.bash_profile (which initializes a bunch of homebrew env vars):

Follow the Next steps instructions to add Homebrew to your PATH and to your bash shell profile script, either ~/.profile on Debian/Ubuntu or ~/.bash_profile on CentOS/Fedora/Red Hat.

test -d ~/.linuxbrew && eval "$(~/.linuxbrew/bin/brew shellenv)"
test -d /home/linuxbrew/.linuxbrew && eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
test -r ~/.bash_profile && echo "eval \"\$($(brew --prefix)/bin/brew shellenv)\"" >>~/.bash_profile
echo "eval \"\$($(brew --prefix)/bin/brew shellenv)\"" >>~/.profile
Enter fullscreen mode Exit fullscreen mode