01-4 Installing Python

01-4 Installing Python

This tutorial will provide detailed instructions on how to install Python on Windows, macOS, and Linux operating systems.

What is Python?

Python is a high-level programming language created by Guido van Rossum, supporting various programming styles and philosophies, and has a clear and concise syntax that is suitable for beginners.

Preparing to Install Python

Before installing Python, you should visit the website where you can download the latest version of the Python software. Typically, you will use the official Python download page.

Installing Python on Windows

  1. Visit the Python download page for Windows.
  2. Download the latest installation file that matches your system.
  3. Once the download is complete, run the installation file. Check the “Add Python to PATH” option and then click “Install Now”.
  4. After the installation is complete, it is recommended to click the “Disable path length limit” option to remove the path length limit.
  5. Open the command prompt and type python --version to verify the installation.

Installing Python on macOS

  1. Visit the Python download page for macOS.
  2. Download the latest version of the macOS installation package file (.pkg).
  3. Open the downloaded file and follow the instructions of the installation wizard to proceed.
  4. After installation is complete, open the terminal and use the python3 --version command to check if the installation was successful.

Installing Python on Linux

The majority of Linux distributions come with Python pre-installed. However, if you need to update to the latest version or perform a new installation, please follow the instructions below:

  1. Open the terminal and update your system packages:
    sudo apt update && sudo apt upgrade
  2. Install Python:
    sudo apt install python3
  3. Once the installation is complete, check the installed version using the python3 --version command.

Installing an Integrated Development Environment (IDE)

It is recommended to install an Integrated Development Environment (IDE) to facilitate Python programming more effectively. Here are some popular IDEs:

PyCharm

PyCharm, provided by JetBrains, is an IDE known for its powerful features and ease of use. The community version is available for free.

Visit the PyCharm download page to download the installation file and install it.

Visual Studio Code

Visual Studio Code, provided by Microsoft, is a code editor famous for its support of multiple languages and rich plugins. You can install the Python extension to use it.

Visit the VS Code download page to download the installation file and install it.

Setting Up a Virtual Environment

It is good practice to set up a virtual environment to manage independent packages and libraries for each Python project. Here is how to set up a virtual environment:

Using the venv Module

  1. Create a virtual environment in the Python 3 environment by entering
    python3 -m venv myenv
    . Here, “myenv” is the name of the virtual environment folder.
  2. Activate the virtual environment. Enter
    source myenv/bin/activate
    (for Windows, use
    .\myenv\Scripts\activate
    ).
  3. To deactivate the virtual environment, use the deactivate command.

Conclusion

This tutorial covered how to install Python on various operating systems and set up a basic integrated development environment. Once you have completed the installation and environment setup, you are now ready to start developing with Python. Experiment with various projects to experience the powerful features of Python. Happy coding!