Setting up a Python environment in macOS
Likewise in a Linux environment, macOS also have Python installed by default. But you need to get an idea of the basic installation steps as it will help with updates and reinstallations.
Getting ready
First of all, install Xcode from the App Store, if you haven't installed it already. And then update the command-line tools with the following command:
$ xcode-select --install
Also, we need to install Homebrew,
a package manager for macOS, for that open terminal and type the following command:
$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
How to do it...
Now you can make use of the Homebrew
package manager to install Python in macOS.
Installing Python
- Search the
Homebrew
for the options we can install:
$ brew search python
This will get a result as follows:

- To install Python 3, you can run the following command:
$ brew install python3
Along with Python 3, brew
will install pip3
and setuptools
.
- To set up the virtual environment...