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.
- Install Now: Default install Python to C drive, built-in IDLE (provides a graphical interface to work with Python), pip and documents, create shortchut, .
- Customize installation: Allows you to select the required installation location and features.
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.
Click Run> Run module or F5 to see the result.
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
You should read it
- What is Python? Why choose Python?
- More than 100 Python exercises have solutions (sample code)
- Why should you learn Python programming language?
- For in Python loop
- Bookmark 5 best Python programming learning websites
- How to set up Python to program on WSL
- 5 choose the best Python IDE for you
- Python data type: string, number, list, tuple, set and dictionary
- Multiple choice quiz about Python - Part 3
- Manage files and folders in Python
- If, if ... else, if ... elif ... else commands in Python
- How to Install Tkinter
Maybe you are interested
This program will help you become invisible before the webcam lens is recording live Brain research explains the difference in the impact of technology on men and women 18 'extremely creative' inventions are available only in Japan Suggest how to mix things for couples on Christmas night 'Eyes glued' to the screen before going to bed is not harmful to the mental health of the bar, teenager! What to eat to increase creativity