Setup Python 3.12 on Windows 11, Linux, and macOS in 2024

pylogo02

It is my gut feeling that Python should come pre-installed in all the operating systems that are being shipped in 2024. Be it mobile or desktop Os’s. For a simple reason that Python has become that default language that has replaced multiple languages that are taught in school these days. Dont get me wrong we still need the equivalents of C and C++ in the school syllabus but nothing comes close to Python when we want to teach programming. Its a sheer joy to use it. But we shouldn’t be required to Setup Python on our machines in future. With that said, Python 3.12 is the latest major release of the Python programming language, and installing it on your machine can help you take advantage of new features, performance improvements, and enhanced developer tools. In this guide, we will walk through the steps to install Python 3.12 on Windows 11, Linux, and macOS machines in 2024.


1. Installing Python 3.12 on Windows 11

Step 1: Download Python 3.12 Installer

  1. Visit the official Python website at https://www.python.org/downloads/.
  2. On the downloads page, click the button for “Python 3.12.0 for Windows.”
    • Ensure you download the correct installer for your system architecture (64-bit or 32-bit).

Step 2: Run the Installer

  1. Locate the installer (python-3.12.x-amd64.exe) in your downloads folder.
  2. Right-click the installer and select Run as Administrator.
  3. In the setup window, check the box that says “Add Python to PATH” (this will allow you to run Python from the command line).
  4. Click on “Install Now”.

Step 3: Verify the Installation

  1. Once the installation completes, open the Command Prompt (search for “cmd” in the Windows start menu).
  2. Type the following command to check if Python was installed successfully:bashCopy codepython --version You should see the output Python 3.12.x confirming the installation.

Step 4: Install pip (if needed)

Python 3.12 typically comes with pip (the Python package installer) pre-installed. To verify:

pip --version

If pip is not installed, you can install it by running the following in PowerShell:

python -m ensurepip --upgrade

2. Installing Python 3.12 on Linux

The method to install Python 3.12 on Linux varies slightly based on the distribution (Ubuntu, Fedora, Arch, etc.), but the general process is the same. Below are installation steps for Ubuntu-based systems, which can be adapted for other distributions.

set up python

Step 1: Update the System Packages

Open a terminal and run the following command to update your system:

sudo apt update && sudo apt upgrade

Step 2: Add the Python 3.12 PPA (Personal Package Archive)

Python 3.12 may not be available in the default package repositories yet, so you’ll need to add a PPA.

sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update

Step 3: Install Python 3.12

Run the following command to install Python 3.12:

sudo apt install python3.12 python3.12-venv python3.12-dev

Step 4: Verify the Installation

Once the installation is complete, check the version by issuing the following command:

python3.12 --version

You should see the output: Python 3.12.x.

Step 5: Set Python 3.12 as the Default Version (Optional)

If you want Python 3.12 to be the default version for the python command, you can set up an alias:

sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.12 1
pylogo02

3. Installing Python 3.12 on macOS

Step 1: Download Python 3.12 Installer

  1. Go to the official Python website: https://www.python.org/downloads/.
  2. Click the “Download Python 3.12.x” button under the macOS section.
    • Download the installer .pkg file.

Step 2: Install Python 3.12

  1. Double-click the downloaded .pkg file to launch the installer.
  2. Follow the on-screen instructions and make sure you check the option to install Python’s command line tools and Add Python to PATH.
  3. Finish the installation.

Step 3: Verify the Installation

Open the Terminal and verify that Python 3.12 was installed correctly by typing:

python3 --version

You should see Python 3.12.x.

Aero Armour Bharatiya T-Shirt

Step 4: Install Homebrew (Optional)

If you prefer to install Python using Homebrew (a popular macOS package manager), follow these steps:

  1. Install Homebrew (if not already installed):bashCopy code/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  2. Use Homebrew to install Python 3.12:bashCopy codebrew install python@3.12

Step 5: Verify pip Installation

Python 3.12 comes with pip, but you can verify its installation by typing:

pip3 --version

If pip is missing, you can install it using:

python3.12 -m ensurepip --upgrade

4. Setting Up Virtual Environments

After installing Python 3.12 on any platform, it’s a good idea to work in virtual environments to isolate project dependencies. Here’s how to create a virtual environment:

  1. Navigate to your project folder or create a new one:bashCopy codemkdir my_project cd my_project
  2. Create a virtual environment using venv:bashCopy codepython3.12 -m venv venv_name
  3. Activate the virtual environment:
    • On Windows:bashCopy codevenv_name\Scripts\activate
    • On Linux/macOS:bashCopy codesource venv_name/bin/activate
  4. Install packages within the virtual environment:bashCopy codepip install package_name
  5. To deactivate the virtual environment, simply run:bashCopy codedeactivate

5. Troubleshooting Tips

  • “Python is not recognized” on Windows: Ensure that Python has been added to your system’s PATH. You can re-run the installer and check the “Add Python to PATH” option or manually add it to the environment variables.
  • Permission issues on Linux: If you encounter permission issues while installing Python or its packages, prepend the commands with sudo.
  • Multiple Python versions: If you have multiple Python versions installed, use python3.12 or create an alias to manage your versions.

Conclusion

Setting up Python 3.12 on Windows 11, Linux, and macOS is a straightforward process that ensures you have the latest features and improvements of this powerful programming language. Whether you’re installing Python for development, data science, or automation tasks, following the steps outlined ensures a smooth installation across all platforms.

For Windows 11 users, downloading the installer and ensuring Python is added to the system’s PATH is crucial for seamless command-line use. Linux users, especially those on Ubuntu, can leverage package managers like apt and PPAs to install the latest version efficiently. macOS users can either use the official installer or Homebrew, a popular package manager for Mac, to install Python.

Additionally, utilizing virtual environments after installation is highly recommended. This isolates project dependencies, ensuring no conflicts arise between different packages across various projects.

By following the proper steps, troubleshooting any potential issues, and setting up virtual environments, you can now take full advantage of Python 3.12’s features across any operating system. Whether you’re a beginner or seasoned developer, having Python 3.12 properly installed is a solid foundation for building efficient and scalable software solutions.

Start your Python tutorial here:

Curated Reads:

Dhakate Rahul

Dhakate Rahul

One thought on “Setup Python 3.12 on Windows 11, Linux, and macOS in 2024

Leave a Reply

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