How to install Python on Windows, macOS, Linux

To get started with Python, you first need to install Python on the computer you are using, be it Windows, macOS or Linux. Below is a guide to installing Python on your computer, specific to each operating system.

In the previous article, we learned about Python well , the advantages and areas that can use this programming language. To get started with Python, you first need to install Python on the computer you are using, be it Windows, macOS or Linux.

What is Python? Why choose Python?

Below is a guide to installing Python on your computer, specific to each operating system.

Install and run Python on Windows

Download Python here: https://www.python.org/downloads/, select the version you need, in this article we choose Python 3.6.

Double click on the downloaded file to install. There are 2 options here, you can choose one to install.

  1. Install Now: Default install Python to C drive, built-in IDLE (provides a graphical interface to work with Python), pip and documents, create shortchut, .
  2. Customize installation: Allows you to select the required installation location and features.

Picture 1 of How to install Python on Windows, macOS, Linux

Open IDLE. To create a new file in IDLE click File> New Windows or press Ctrl + N.

Copy the Python code:

 print("Xin chào!") 

Go to the file you just created, then press Ctrl + S to save. The file will have a extension called .py, give it a name, such as: quantrimang-python.py.

Picture 2 of How to install Python on Windows, macOS, Linux

Click Run> Run module or F5 to see the result.

Picture 3 of How to install Python on Windows, macOS, Linux

It is very simple and easy, isn't it? Now you have finished running the first Python program already.

Install and run Python on Ubuntu

Install the following denpendency:

$ sudo apt-get install build-essential checkinstall
$ sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev

Download Python here: https://www.python.org/downloads/

In the terminal, go to the directory containing the downloaded file and run the following command to extract the file. The file name will vary depending on the version you downloaded.

 $ tar -xvf Python-3.6.2.tgz 

Go to the unzipped folder, enter the command:

 $ cd Python-3.6.0 

Execute the following commands to compile Python source code on Ubuntu.

 $ ./configure 
$ make
$ make install

If you are a new user, you should install Sublime Text on your computer to write Python code on Linux. Enter the following command to install:

 $ sudo add-apt-repository -y ppa:webupd8team/sublime-text-2 
$ sudo apt-get update
$ sudo apt-get install sublime-text

Open Sublime Text, go to File> New File or press Ctrl + N to create a new file.

Save the file with the option name, such as quantrimang-python.py

Write the code and save it:

 print("Xin chào!") 

Go to Tool> Build (Ctrl + B) and you will see the results of the command line at the bottom of the Sublime Text window.

And so, you've just finished running your first Python program on Ubuntu.

Install and run Python on macOS

Download Python: https://www.python.org/downloads/

Open the downloaded file to install according to the instructions, a successful installation message will appear when finished

You can use your favorite code-writing application or use Sublime Text (a tool that many programmers love).

Open up your code editor, create a new file, save with the extension .py

Write the following code and save:

 print("Xin chào!") 

Depending on your code editor that the command to run the code will be different, for Sublime Text press Ctrl + B to see the results when running the command.

So here you have to run the first Python command yourself.

Let's learn another simple program on Python before we start getting used to the basic components of this programming language.

Next article: Keywords and identifiers in Python

Update 25 May 2019
Category

System

Mac OS X

Hardware

Game

Tech info

Technology

Science

Life

Application

Electric

Program

Mobile