Python

Setting Up Python on Your Desktop in 2 Simple Steps | Python Programming

Published

on

Table of Contents

  • macOS
  • Ubuntu Linux
  • This series is about programming computers with Python. You could read this article from cover to cover without ever touching a keyboard, but you’d miss out on the fun part—coding! To get the most out of this series, you need a computer with Python installed on it and a way to create, edit, and save Python code files.

    In this chapter, you’ll learn how to:

    Install the latest version of Python 3 on your computer

    Open IDLE, Python’s built-in Integrated Development and Learning Environment

    Let’s get started!

    A Note on Python Versions

    Many operating systems, including macOS and Linux, come with Python preinstalled. The version of Python that comes with your operating system is called the system Python.

    IMPORTANT

    “Do not attempt to uninstall the system Python!”

    This chapter demonstrates how to install the latest Python 3 version alongside any existing Python system on your computer.

    This chapter is split into three sections: Windows, macOS, and Ubuntu Linux. Find the section for your operating system and follow the steps to get set up, then skip ahead to the next chapter.

    If you have a different operating system, then check out “Python 3 Installation & Setup Guide” to see if your OS is covered.

    Windows

    Follow these steps to install Python 3 and open IDLE on Windows.

    IMPORTANT

    “The code in this chapter is tested only against Python installed as described in this section. Be aware that if you have installed Python through some other means, such as Anaconda Python, you may encounter problems when running some of the code examples!”

    Install Python

    Windows doesn’t typically come with a system Python. Fortunately, installation involves little more than downloading and running the Python installer from the Python.org website.

    Step 1: Download the Python 3 Installer

    Open a web browser and navigate to the following URL:

    https://www.python.org/downloads/windows/

    Click Latest Python 3 Release – Python 3.x.x located beneath the “Python Releases for Windows” heading near the top of the page. As of this writing, the latest version was Python 3.12.

    Then scroll to the bottom and click Windows x86-64 executable installer to start the download.

    Note “If your system has a 32-bit processor, then you should choose the 32-bit installer. If you aren’t sure if your computer is 32-bit or 64-bit, stick with the 64-bit installer mentioned above.”

    Step 2: Run the Installer

    Open your Downloads folder in Windows Explorer and double-click the file to run the installer. A dialog that looks like the following one will appear:

    The Python version you see is acceptable if it’s greater than 3.12.2, as long as it’s not less than 3.

    IMPORTANT

    “Make sure you select the box that says Add Python 3.x to PATH. If you install Python without selecting this box, then you can run the installer again and select it.”

    Click Install Now to install Python 3. Wait for the installation to finish, then continue to open IDLE.

    Open IDLE

    You can open IDLE in two steps:

    1. Click the Start menu and locate the Python 3.12 folder.

    2. Open the folder and select IDLE (Python 3.12).

    IDLE opens a Python shell in a new window. The Python shell is an interactive environment that allows you to type in Python code and execute it immediately. It’s a great way to get started with Python!

    The Python shell window looks like this:

    The Python version and operating system information are displayed at the top of the window. If Python version is less than or greater 3.12, follow the previous installation instructions.

    Now that you have Python installed, let’s get straight into writing your first Python program!

    macOS

    Follow these steps to install Python 3 and open IDLE on macOS.

    IMPORTANT

    “The code in this chapter is tested only against Python installed as described in this section. Be aware that if you have installed Python through some other means, such as Anaconda Python, you may encounter problems when running some of the code examples!”

    Install Python

    Windows doesn’t typically come with a system Python. Fortunately, installation involves little more than downloading and running the Python installer from the Python.org website.

    Step 1: Download the Python 3 Installer

    Open a web browser and navigate to the following URL:

    https://www.python.org/downloads/windows/

    Click Latest Python 3 Release – Python 3.x.x located beneath the “Python Releases for Windows” heading near the top of the page. As of this writing, the latest version was Python 3.12.

    Then scroll to the bottom and click Windows x86-64 executable installer to start the download.

    Step 2: Run the Installer

    Open your Downloads folder in Windows Explorer and double-click the file to run the installer. A dialog that looks like the following one will appear:

    Press Continue a few times until you are asked to agree to the software license agreement. Then click Agree. You’ll be shown a window that tells you where Python will be installed and how much space it will take. You most likely don’t want to change the default location, so go ahead and click Install to start the installation.

    When the installer is finished copying files, click Close to close the installer window.

    Open IDLE

    You can open IDLE in three steps:

    1. Open Finder and click Applications.

    2. Double-click the Python 3.12 folder.

    3. Double-click the IDLE icon.

    IDLE opens a Python shell in a new window. The Python shell is an interactive environment that allows you to type in Python code and execute it immediately. It’s a great way to get started with Python!

    The Python shell window looks like this:

    The Python version and operating system information are displayed at the top of the window. If Python version is less than or greater 3.12, follow the previous installation instructions.

    Now that you have Python installed, let’s get straight into writing your first Python program!

    Ubuntu Linux

    Follow these steps to install Python 3 and open IDLE on Ubuntu Linux.

    IMPORTANT

    “The code in this chapter is tested only against Python installed as described in this section. Be aware that if you have installed Python through some other means, such as Anaconda Python, you may encounter problems when running some of the code examples!”

    Install Python

    There’s a good chance that your Ubuntu distribution already has Python installed, but it probably won’t be the latest version, and it may be Python 2 instead of Python 3. To find out what version(s) you have, open a terminal window and try the following commands:

    $ python --version
    
    $ python3 --version

    One or more of these commands should respond with a version, as below:

    $ python3 --version
    

    To install Python on Ubuntu, determine your local version by running the command:

    $ lsb_release -a
    
    No LSB modules are available.
    
    Distributor ID:                 Ubuntu
    
    Ubuntu Description:             Ubuntu 18.04.1 LTS
    
    Release:                        18.04
    
    Codename:                       bionic

    Look at the version number next to Release in the console output and follow the corresponding instructions below.

    Ubuntu 18.04 or Greater

    Ubuntu 18.04 does not automatically include Python 3.12, but it can be installed using the following commands in the Terminal application.

    $ sudo apt-get update
    
    $ sudo apt-get install python3.12 idle-python3.12 python3-pip

    Note that because the Universe repository is usually behind the Python release schedule, you may not get the latest version of Python 3.12. However, any version of Python 3.12 will work for this chapter.

    Ubuntu 17 and Lower

    For Ubuntu versions 17 and lower, Python 3.12 is not in the Universe repository. You need to get it from a Personal Package Archive (PPA). To install Python from the deadsnakes PPA, run the following commands in the Terminal application.

    $ sudo add-apt-repository ppa:deadsnakes/ppa
    
    $ sudo apt-get update
    
    $ sudo apt-get install python3.12 idle-python3.12 python3-pip

    You can check that the correct version of Python was installed by running python3 –version. If you see a version number less than 3.12, then you may need to type python3.12 –version. Now you can open IDLE and get ready to write your first Python program.

    Open IDLE

    You can open IDLE from the command line by typing the following:

    $ idle-python3.12

    On some Linux installations, you can open IDLE with the following shortened command:

    $ idle3

    IDLE opens a Python shell in a new window. The Python shell is an interactive environment that allows you to type in Python code and execute it immediately. It’s a great way to get started with Python!

    The Python shell window looks like this:

    The Python version and operating system information are displayed at the top of the window. If Python version is less than or greater 3.12, follow the previous installation instructions.

    Now that you have Python installed, let’s get straight into writing your first Python program!

    Go ahead and move on to chapter 3.

    Trending

    Exit mobile version