The .bashrc file (for Linux or other Bash environments) and the .zshrc files (for MacOS or other Zsh environments) are both files on your local system used to create aliases, which are like keyboard shortcuts for your shell or terminal. Zshrc is more in-depth as it can not only be used to set aliases but can also include setup scripts and default environment variables. In this article, we’ll just be covering aliases, using either .bashrc or .zshrc.
As an example, we’ll be setting the aliases for ‘python’ and ‘pip’ in your local shell.
*If you’re using pyenv to manage your Python versions, then you can just follow the steps below to set up an alias for ‘pip’, as pyenv already handles the ‘python’ alias for you.
My .bashrc file
Where art thou?
The .bashrc file is located here: ~/.bashrc
The .zshrc file is located here: ~/.zshrc
If you’re like most even casual Python developers, you’ve worked with Python 2, which was the standard for years. The Python Software Foundation announced the End of Life (EOL) for Python 2, meaning the core development team will no longer support, update or provide new versions of Python 2 as of January 1, 2020. Please see Sunsetting Python 2 on Python.org for more details - https://www.python.org/doc/sunset-python-2/)
With the upgrade from Python 2 to Python 3, also came the upgrade from pip, the package installer for Python 2, to pip3, the package installer for Python3.
This left a lot of people wondering, including myself, which versions of Python and Pip am I invoking when I type 'python' or 'pip'. Is it version 2 or version3?
Instead of always wondering or worrying which version you’re using, let’s set it up so we’re ALWAYS referring to Python 3 and pip 3 when we type the aliases ‘python’ or ‘pip’.
The instructions below cover Linux and Mac OS systems. If you’re on a Windows system and want to create aliases for ‘python’ and ‘pip’ to refer to their version 3 incarnations, the process is completely different, so please see this article: