How to install Python on Windows, Mac, Ubuntu

Python is one of the most popular programming languages today. It’s used not only to build apps and websites but also by data analysts for their analysis work. To get started, you need to install Python on Windows, Mac or Ubuntu, depending on your operating system. In this article, I’ll walk you through installing Python on all three.

Install Python on Windows and macOS

Installing Python on Windows and Mac works the same way. Let’s start with 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 installer you just downloaded. Just keep clicking the Continue button until the installation finishes.

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

Note: On Windows, make sure to check the Add Python to PATH box so you can run Python files in 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: Once the installation is done, you’ll have a Python folder like this. You can open IDLE to start using Python.

Python installed successfully on Mac and Windows
Python installed successfully on Mac and Windows

Step 4: You need Pip to create virtual environments and install packages. Open CMD on Windows or Terminal on Mac, then run the following commands one by one to install Pip:

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 the Pip installation file on Mac (or Linux):

rm -rf get-pip.py

Delete the Pip installation file on Windows (CMD):

del get-pip.py
Install Pip on Windows and Mac
Install Pip on Windows and Mac

Install Python on Ubuntu

Ubuntu comes with Python by default. But if you need a specific Python version, follow these steps:

Step 1: If you use Ubuntu Server, connect to your machine via SSH. If you use Ubuntu Desktop, open the Terminal app.

Step 2: Check the default Python version on Ubuntu. If it isn’t the version you need, continue with the installation step below.

python3 --version

Step 3: Run the commands below to install Python on Ubuntu.

Install Python on Ubuntu
Install Python on Ubuntu

Update the package list in Ubuntu:

sudo apt update

Install Python on Ubuntu: Replace 3.10 with the version you need.

sudo apt install python3.10

Install Pip on Ubuntu:

sudo apt install python3-pip

A quick Python test

Open CMD on Windows or Terminal on Mac and Ubuntu. Try the commands below to check that Python works on your computer.

Check that Python works on your computer
Check that Python works on your computer

Check the Python version:

python --version

Start Python and print a message:

python
print("Hello world!")

Exit Python:

exit()

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

Use a Python virtual environment

You’ll usually need to install extra packages for your work and projects. However, libraries can conflict with each other and even break the default Python environment. That’s why it’s a good idea to create a separate virtual environment for each project.

For this part, I recommend reading Python’s documentation because I find it very clear and helpful. If you work in data science, check out how to create a Python virtual environment using Conda.

Conclusion

With this tutorial, you should now have Python fully installed on Windows, Mac or Ubuntu. Along with Python, data analysts often install SQL Server on Mac or Windows for learning and exploring data. Follow the data analysis articles on Lucid Gen for more, and if you have any questions, feel free to leave a 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 (preferably in English), 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.