How to Install Python on macOS

How to Install Python on macOS

Table of Contents

Like installing Python on a Windows computer, installing Python can be done in a number of ways, which this article will cover. Check out the Python course online to learn more.

  • Install Python straight from the Python website: This approach lets you personalise your installation and has more control over the process.
  • Using an Anaconda distribution, install Python: Popular Python distribution Anaconda is a fantastic choice for scientific computing and data research because it comes with a lot of pre-installed tools and packages.

Checking if Python is Already Installed on Your macOS Machine

Follow these steps to see if Python is installed on your macOS computer:

How to Install Python on macOS
  • Navigating to the Applications folder or using Spotlight search to look up Terminal will launch the app.
  • Enter python3 into the command line. If Python is installed, the Python prompt, which looks like this “>>>,” should appear after a notification stating something like “Python 3.x.x.” The version number of Python is “3.x.x”.
  • An error message claiming that Python cannot be found will appear if Python is not installed on your computer.

How to Install Python on macOS from the Python Website

Use the complete Python installer from the Python website to install Python on your macOS computer by following these steps:

  • Visit the link to get Python.
  • Click the link for the most recent version of Python (for example, Python 3.11.1 as of this writing) under the “Python Releases for macOS” section.
  • Click the “macOS 64-bit universal2 installer” link under the “Files” section of the Python download page.
  • Double-clicking the downloaded file will launch the installation procedure.
  • After the installer begins extracting files and the installation process is finished, click Continue and check the licence agreement to finish the installation. It could ask for your admin password in order to finish the installation.
  • To exit the installer after the installation is finished, click the “Close” button.
  • To verify that Python has been installed correctly, follow the directions in the section “Checking if Python is Already Installed on Your macOS Machine” after the installation is finished.

How to Install Python on macOS Using Anaconda

Different Python distributions have the necessary tools and packages pre-installed. With a plethora of data science tools and packages pre-installed, the Anaconda Python installation is one of the most widely used distributions. Use an Anaconda distribution to download Python by doing the following steps:

  • Find out what kind of CPU your Mac has. Choose “About This Mac” by clicking on the Apple logo located in the upper left corner of your desktop. Note the value in the “Chip” row in the Overview pane.
  • Visit the download page for Anaconda.
  • You can find various versions of the Anaconda Installer by scrolling down to the “Anaconda Installers” section. If the CPU on your Mac is of the “Apple M1” type, select “64-Bit (M1) Graphical Installer”. Otherwise, click on “64-Bit Graphical Installer”.
  • Double-clicking the downloaded file will launch the installation procedure.
  • After the installer begins extracting files and the installation process is finished, click Continue and check the licence agreement to finish the installation.
  • You will also be prompted to install JetBrains’ DataSpell data science IDE after the installation is finished.
  • You will get a screen that reads “Installation was completed successfully” if the installation is successful. Click “Finish.”
  • To verify that Python has been installed correctly, follow the directions in the section “Checking if Python is Already Installed on Your macOS Machine” after the installation is finished.

How to Install Python Packages

Python has a vast ecosystem of packages that offer the capability for particular data science jobs, and it is modular. For instance, the pandas package offers data manipulation capabilities; scikit-learn offers machine learning capabilities; and PyTorch offers deep learning capabilities.

How to Install Python on macOS

Pip3 and conda are the two package management systems available for installing Python packages. You can install and update Python packages with the help of these tools.

1.Installing packages with pip3

If you installed Python through the Microsoft Store or the Python website, use pip3.   

To install packages using pip3, take the following actions:

  • Make sure Python is installed on your computer before attempting to install Python packages. Use one of the preceding sections’ steps (for example, downloading and installing via the Microsoft Store from the website) to install Python.
  • In order to install a package using pip3, launch the Command Prompt on Windows or the Terminal on macOS, and enter the following command: 

pip3 install {package_name}

  • Installing a package is indicated by the {package_name} in this case. For instance, you would type the following to install the numpy package:

pip3 install numpy

Pip3 will automatically install additional packages if a package has dependencies, meaning that it needs them to work.

  • After installing the package, you can import it into your Python code.
  • Using the pip3 install –upgrade command, you can update a package to the most recent version. 
  • Use the pip3 uninstall command to remove a package from your system. 
  • Use the pip3 freeze command to get an installation list of every package.

2.Installing packages with conda

If you installed Python using Anaconda, use conda. You don’t need to install common packages yourself because conda already has a lot of Python packages installed for data science.

Use these procedures to install packages using conda:

  • Make sure Python is installed on your computer before attempting to install Python packages. Use the directions in one of the preceding sections (for example, downloading and installing from Anaconda) to install Python.
  • Open a Terminal window on macOS or a Command Prompt window on Windows, then enter the following command to install a package using conda:

conda install {package_name}

  • The conda update command can be used to update a package to the most recent compatible version. 

Utilizing the conda remove command, you can remove a package.

  • Use the list command in conda to get a list of all the installed packages.

Conclusion Check out the Python training online to learn more about how to install Python.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Share this article
Subscribe
By pressing the Subscribe button, you confirm that you have read our Privacy Policy.
Need a Free Demo Class?
Join H2K Infosys IT Online Training
Enroll Free demo class