Easy
  Python
    Guide

Installing Python

Checking if Python is Already Installed

Before installing Python, you should first check if it's already installed on your system. Open your command prompt (Windows) or terminal (Mac/Linux) and type the following command:


        python --version
      

If Python is installed, this will display the version number, such as "Python 3.11.2". On some systems, particularly Linux and Mac, you might need to use


        python3 --version
      

instead. If you see an error message like "python is not recognised as an internal or external command" (Windows) or "command not found" (Mac/Linux), then Python is not installed or not properly added to your system's PATH.

Checking if PIP is Installed

PIP (Pip Installs Packages) is Python's package installer and typically comes bundled with Python installations from version 3.4 onwards. To check if PIP is installed, use this command:


        pip --version
      

Similar to Python, you might need to use:


        pip3 --version
      

on some systems. If PIP is installed, you'll see version information and the Python version it's associated with. If you get an error message, PIP either isn't installed or isn't in your system's PATH.

Installing Python on Windows

To install Python on Windows, visit the official Python website at python.org and download the latest stable version. Run the installer and make sure to check the box that says "Add Python to PATH" during installation - this is crucial for using Python from the command prompt. The installer will automatically include PIP. After installation, restart your command prompt and verify the installation using the commands mentioned above.

Installing Python on Mac

Mac users have several options for installing Python. The easiest method is to download the official installer from python.org. Alternatively, if you have Homebrew installed, you can use:


        brew install python
      

Another popular option is using pyenv for managing multiple Python versions:


        brew install pyenv
        pyenv install 3.11.2
        pyenv global 3.11.2
      

After installation, you may need to add Python to your PATH by editing your shell profile file (.bash_profile, .zshrc, etc.).

Installing Python on Linux

Most Linux distributions come with Python pre-installed, but it might be an older version. To install the latest Python on Ubuntu or Debian-based systems, use:


        sudo apt update
        sudo apt install python3 python3-pip
      

For Red Hat, CentOS, or Fedora systems:


        sudo yum install python3 python3-pip
      

Or for newer Fedora versions:


        sudo dnf install python3 python3-pip
      

Installing PIP Separately

If Python is installed but PIP is missing, you can install PIP separately. Download get-pip.py from the official PIP installation page, then run:


        python get-pip.py
      

On Linux or Mac, you might need to use:


        python3 get-pip.py
      

Alternatively, on Linux systems, you can often install PIP using your package manager as shown in the previous section.

What is an IDE and Why Use One?

An IDE (Integrated Development Environment) is a software application that provides comprehensive facilities for software development. An IDE typically includes a code editor with syntax highlighting, debugging tools, project management features, and integration with version control systems. While you can write Python code in any text editor, an IDE makes programming much more efficient by providing features like auto-completion, error detection, code formatting, and the ability to run and debug your programs directly within the interface.

Best Free Python IDEs

Several excellent free IDEs are available for Python development. Visual Studio Code (VS Code) is arguably the most popular choice, offering excellent Python support through extensions, integrated terminal, debugging capabilities, and Git integration. VS Code is not limited to Python, so you can use the same IDE to code projects in various languages. PyCharm Community Edition is a powerful IDE specifically designed for Python, featuring intelligent code completion, debugging, and testing tools. IDLE comes bundled with Python and provides a simple environment perfect for beginners. Thonny is another beginner-friendly IDE with a clean interface and built-in debugger that visualises code execution.

Setting Up Your IDE for Python

To set up VS Code for Python, install the Python extension from the Extensions marketplace, which provides syntax highlighting, IntelliSense, debugging, and formatting. For PyCharm, simply download and install the Community Edition, and it will automatically detect your Python installation. Most IDEs will allow you to configure which Python interpreter to use, which is important if you have multiple Python versions installed. You can usually find this setting in the IDE's preferences or project settings, where you can specify the path to your Python executable.

◄ What is Python Used For? | Basic and Compund Data Types ►