Virtual Environments I: Installing Pyenv with Homebrew

If you’ve used Python before, you may have encountered a situation known as “dependency hell”. Some packages depend on other packages to work. Sometimes, the package that another package depends on must be a certain version. Later on, you might need to use a different version of that package because there is yet another package that depends on that package being another version. So the best way to avoid dependency hell and create professional projects is to use virtual environments.

a lego toy office worker frustrated in front of a tiny computer
Image by www_slon_pics from Pixabay

I. Installing Pyenv with Homebrew

bash-3.2$
username@user-computer$ 
bash
$ brew update
$ brew install pyenv

II. Using Bash and Nano to Create a .bash_profile

$ ls -a
$ nano
screen shot of a nano file
screen shot of a nano file
screen shot of a nano file
echo ‘export PYENV_ROOT=”$HOME/.pyenv”’ >> ~/.bash_profile
echo ‘export PATH=”$PYENV_ROOT/bin:$PATH”’ >> ~/.bash_profile
eval “$(pyenv init -)”
 exec $SHELL

III. Using Pip to Install Virtualenv

$ pip3 install virtualenv
$ pip3 install virtualenvwrapper
$ brew install pyenv-virtualenv
eval “$(pyenv virtualenv-init -)”

IV. What Did We Do?

V. What’s Next?

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store