Catalina, zsh, bash and conda environments
I upgraded my operating system to Mac OS Catalina recently and found myself having to deal with strange python behaviour. One important change on Catalina vs Mojave is that the default terminal shell (=command interpreter) is now zsh and not bash anymore. So if you had python installed on Mojave or earlier versions tailored to bash, these are the adjustments you need to do:
- Get Oh-my-zh
- Configure ~.zsh_profile
- Configure Catalina and conda environments
Why did they change to ZSH in the first place? Well, because it exhibits improvements and higher flexibility over bash. The name 'zsh' is derived from the name of Yale professor Zong Shao. Some improvements over bash include themes and plugins, automatic cd, recursive path expansion, spelling correction, approximate completion, plugin and theme support. You can find more infos on zsh here.
First step: Install homebrew (if not done already)
Homebrew is a useful tool to install software on macOS operating systems and Linux with the command line. Another way of saying that it's ' a package management system'. For example in python, the package management systems are a) anaconda and b) pip, and for LaTeX, the package manger is tlmgr.
For homebrew you need to
a) install Xcode via Mac App Store b) install command line tools (130MB) with xcode-select --install c) install Homebrew with : /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Second step: Configure ZSH and get Oh-my-zsh
Oh-my-zsh is an open source framework for managing ZSH.
Do you have zsh already?
If yes, install Oh-my-zh by typing
brew install wget wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | zsh
Oh-my-zsh is installed in the home directory '~/.oh-my-zsh'
Next, create a new configuration for zsh. As with the bash shell, which has a configuration named '.bashrc', for zsh, we need a
.zshrc configuration file. It's available in the oh-my-zsh templates directory.
Copy the template
.zshrc.zsh-template configuration file to the home directory
.zshrc and apply the configuration by running the source command:
cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc source ~/.zshrc cd ~/.oh-my-zsh/themes/ ls -a vim ~/.zshrc
and then change the theme you want, e.g.
We need to configure the .zshr for python
Which python is in your PATH? (Or which exectuable is triggered when typing
However, we are not done yet. What would happen now is that every time I started a new terminal session, I needed to adjust my PATH variable. Annoying! I found the solution on overflow: