How to install Python on Windows, Mac, Ubuntu

The most popular programming language today is Python. Python is used not only for application programming and website design but also by data analysts for analysis. To use Python, you need to install Python on Windows, Mac, and Ubuntu, depending on your operating system. In this article, Lucid Gen will guide you through installing Python for all three operating systems.

Install Python on Windows and macOS

How to install Python on Windows and Mac will be the same. We will start installing Python according to the steps below:

Step 1: Visit python.org/downloads and click the Download Python button.

Download Python to install on Windows and Mac
Download Python to install on Windows and Mac

Step 2: Open the downloaded installation file to install Python on Windows and Mac. Just keep clicking the Continue button until the Python installation is successful.

Install Python on Mac and Windows
Install Python on Mac and Windows

Note: For Windows, you must check the Add Python to PATH box to run the Python file on CMD.

Remember to select Add Python to PATH when installing Python on Windows
Remember to select Add Python to PATH when installing Python on Windows

Step 3: After successfully installing Python on Windows or Mac, you will have a Python folder like this. You can open the IDLE file to use Python.

Install Python on Mac and Windows successfully
Install Python on Mac and Windows successfully

Step 4: We must install Pip to create a virtual environment for Python and install packages. Open the CMD application on Windows or Terminal on Mac, then enter the following lines of code sequentially to install Pip on your computer:

Download the Pip installation file:

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py

Start installing Pip:

python get-pip.py

Delete Pip installation file:

rm -rf get-pip.py
Install Pip on Windows and Mac
Install Pip on Windows and Mac

Install Python on Ubuntu

By default, Ubuntu already has Python available. But if you need to install a specific version of Python, then follow these steps:

Step 1: If you use Ubuntu Server, access your computer using SSH; if you use Ubuntu Desktop, open the Terminal application.

Step 2: Check the default Python version on Ubuntu. If the version you need is incorrect, we will go to the step of installing Python on Ubuntu below.

python3 --version

Step 3: Enter the code lines below to install Python for Ubuntu.

Install Python on Ubuntu
Install Python on Ubuntu

Update software packages in Ubuntu:

sudo apt update

Install Python on Ubuntu: Change version 3.10 to the version you need.

sudo apt install python3.10

Install Pip on Ubuntu:

sudo apt install python3-pip

Using Python is simple

Open the CMD application on Windows or the Terminal application on Mac and Ubuntu. Try a few commands below to check if Python works well on your computer.

Check if Python is already working on your machine
Check if Python is already working on your machine

Check the Python version:

python --version

Using Python:

python
print("Hello world!")

Exit Python:

exit()

Note: For macOS and Ubuntu, if the command python doesn’t work, use python3.

Use the Python virtual environment

Usually, we will need to install additional packages to serve our work and projects. However, libraries can conflict with each other and can break the default Python environment. Therefore, for a particular project, we should create a separate virtual environment for it.

For this part, you should read more of Python’s documentation because I find their documentation to be very instructive. But if you are a data scientist, please refer to how to create a Python virtual environment using Conda.

Conclusion

This tutorial lets you install Python on Windows, Mac, and Ubuntu completely. Along with Python, data analysts will install SQL server on Mac or Windows to facilitate learning and exploration. Please follow articles related to data analysis on Lucid Gen. If you need any answers, please comment below.

Hieu Tran Ngoc Minh

Hieu (born in 1996) holds a Bachelor's degree in Business Administration from Saigon Technology University. Currently a Data Analyst at Ninja Van, Hieu has extensive experience in Data Analysis and Digital Marketing. This blog is where Hieu shares practical experiences from work and life.

Leave a Comment

Feel free to leave your comment, and we will review and respond as soon as possible. Please use a real email to ensure your comment is approved and to receive notifications when we reply. You can also add an avatar to your email.