Skip to main content

How to Install Python

How to Install Python

If you're new to programming or looking to dive into the world of Python, you'll need to install Python on your computer to get started.

How to install Python?

To install Python on your computer, follow these steps:

  1. Visit the official Python website:
  2. Navigate to the Downloads section.
  3. Choose the version of Python you want to install.
  4. Select the appropriate installer for your operating system. Python is available for Windows, macOS, and Linux.
  • For Windows: Download the executable installer (.exe file).
  • For macOS: Download the macOS installer (.pkg file).
  • For Linux: Most Linux distributions come with Python pre-installed. However, if you need a specific version or want to install Python from scratch, you can download the source code and follow the instructions provided.
  1. Once the installer is downloaded, run the executable file.
  2. On Windows, you may need to check the option "Add Python to PATH" during the installation.
  3. Follow the instructions in the installer to complete the installation process. You can generally accept the default settings.
  4. After the installation is complete, open the command prompt (on Windows) or the terminal (on macOS and Linux) and type python --versionto verify that Python has been installed correctly. You should see the version number displayed.

That's it! You have successfully installed Python on your computer. You can now start writing and running Python programs.

How to Run a Python Script from a Command Line

To run a Python script from the command line, follow these steps:

  1. Open the command prompt (Windows) or the terminal (macOS/Linux).
  2. Navigate to the directory where your Python script is located. You can use the cd command followed by the directory path to change to the desired directory. For example, if your script is located in the Documents folder, you can use the following command:
cd Documents
  1. Once you are in the correct directory, you can run the Python script by typing python followed by the name of the script file. For example, if your script file is named, use the following command:

If you have multiple versions of Python installed on your system, you may need to specify the version explicitly. In that case, use the following command instead:


If you're using Python 2.x, the command would simply be python without the "3".

  1. Press the Enter key, and the Python script will execute. You will see the output or any error messages displayed in the command prompt or terminal.

That's it! You have successfully run a Python script from the command line. Remember to navigate to the correct directory where your script is located before executing the python command.

Contribute with us!

Do not hesitate to contribute to Python tutorials on GitHub: create a fork, update content and issue a pull request.

Profile picture for user angarsky
Full-stack web developer, machine vision engineer.
Updated: 05/03/2024 - 22:38