DEV Community

loading...

Setup python 3 environment on mac with zsh

kgoedert profile image kgoedert Originally published at dev.to ・1 min read

Trying to setup my development enviroment on a mac, I had some problems, specially integrating my virtual environment information on my shell. On zsh specifically, with oh my zsh. The theme am I using is PowerLevel9k

The steps that worked:

Installation

  • Install homebrew

  • Install python 3 and pip 3 with brew. Installing python 3 also installs pip3

brew install python3
sudo pip3 install virtualenvwrapper

Usually in python projects you do not install packages with sudo, but this way virtualenvwrapper will be installed globally and available to all the projects

ZSH Configuration

Edit your ~/.zshrcand:

  • Enable virtualenv plugin on .zshrc
 plugins=(...virtualenv)
  • Set python 3 as the default for virtualenvwrapper
export VIRTUALENVWRAPPER_PYTHON='/usr/bin/python3'
  • Load virtualenvwrapper script
source /usr/local/bin/virtualenvwrapper.sh
  • To be able to show the active virtualenv on the prompt add (I just added the virtualenv, the others are the default ones)
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context dir vcs virtualenv)
  • Edit your ~/.oh-my-zsh/plugins/virtualenv/virtualenv.plugin.zsh and comment out the line
export VIRTUAL_ENV_DISABLE_PROMPT=1
  • source your zsh
source ~/.zshrc

Discussion (2)

Collapse
romkatv profile image
Roman Perepelitsa

There is powerlevel10k now. You might want to upgrade.

Collapse
rediffusion profile image
Forem Open with the Forem app