Python, an interpreted, high-level, general-purpose programming language, is one of the most popular programming languages in the world.
It offers an easy-to-learn syntax that makes it a powerful tool for rapid application development.
However, installing Python can be a daunting task, particularly when you need multiple versions or face conflicting packages.
In this article, we’ll explore a unique, user-preferred way to install Python using Homebrew and symbolic links (symlinks).
Homebrew is an open-source software package management system that simplifies the installation of software on Apple’s macOS operating system. It’s widely known as the “missing package manager for macOS.”
The commands involved in this approach are as follows:
brew unlink python
brew unlink python3
# install the latest version of python
ln -s `which python3` /usr/local/bin/python
ln -s `which pip3` /usr/local/bin/pip
pip install --upgrade pip
Now let’s break this down to understand what each command does:
brew unlink python and
brew unlink python3:
These commands are used to unlink the existing python and python3 installations in the system. Unlinking means that Homebrew will ‘disconnect’ the existing python versions from your environment, making way for the new installations.
2. Install the latest version of Python
Go to https://www.python.org/downloads/ and select the latest version to install.
ln -s `which python3` /usr/local/bin/python and
ln -s `which pip3` /usr/local/bin/pip:
These commands are responsible for creating symbolic links (symlinks), or soft links, which are a type of file that serves as a reference to another file or directory.
which python3 and
which pip3 portions of the commands locate the paths where python3 and pip3 are installed. The
ln -s command then creates a symbolic link to these paths at
This approach is beneficial because it ensures that whenever you type
pip in the terminal, the system will refer to the latest python3 and pip3 versions. It provides an efficient way to handle versioning and usage of Python and Pip in your macOS.
pip install --upgrade pip:
Finally, this command is used to upgrade Pip, which is a package manager for Python. Upgrading Pip ensures that you have the latest functionalities and security updates that come with the newer versions.
This particular user-preferred installation approach is advantageous as it offers greater control over the Python version being used, better handling of potential conflicts, and smoother operation with other packages.
Remember, this approach, like any other, requires a certain level of understanding and comfort with the terminal. Always ensure to have a good understanding of the commands you are executing to avoid any unintentional consequences.
Python installation can vary significantly based on your specific use case and preferences. The approach outlined here provides a user-defined method for installing Python that leverages the power of Homebrew and symbolic links to provide a customizable and efficient installation method.