DEV Community

kgoedert
kgoedert

Posted on • Originally published at dev.to

11

Setup python 3 environment on mac with zsh

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

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (2)

Collapse
 
romkatv profile image
Roman Perepelitsa

There is powerlevel10k now. You might want to upgrade.

Collapse
 
rediffusion profile image
rediffusion • Edited

Yes, and it's faster!

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay