Python 3 Installation & Setup Guide

Photo by David Clode on Unsplash

Python 3 Installation & Setup Guide

Installing python3 is the first step to becoming a Python developer, This tutorial will help you install python3 as well as pip3 to install Python packages on your local system in the latest and most stable way possible.

Install Python3 on Ubuntu

Open your terminal (Ctrl + Alt + T), if this command does not work then open it manually by searching the terminal.

Update your local system repository list

sudo apt update

Install software-properties-common to add PPA (Personal Package Archive)

sudo apt install software-properties-common

Now add Deadsnakes PPA. Dead Snakes is a PPA with newer releases than Ubuntu's default repositories

sudo add-apt-repository ppa:deadsnakes/ppa

Update your local system repository list again

sudo apt update

Download the latest version of python3

sudo apt install python3

To install any other version, you can modify the above command like this

sudo apt install python3.8

Now check your Python version

python3 -V

You should see your Python version installed like this

Python 3.8.10 #it may vary as per your installation

Now install pip3

sudo apt install python3-pip

That's it [OPTIONAL] It is good practice to work in virtual environment

Install Python3 on macOS

Download the required macOS installer from the python.org official website, and select the Download Python3.x button.

Locate the file using Finder, and double-click the package file. Following the installation prompts.

You can now confirm successful installation by checking for Python 3 as shown below

python3 -V # Output Python 3.7.2

You can similarly check that pip3 is installed by listing the available packages:

pip3 list

Install Python3 on Windows

Windows 10 users

Microsoft has a Python application available in the Microsoft Store and it is also the recommended way of installing Python. It handles auto-updates and PATH variable issues.

To install Open Microsoft store and search Python.

Click on the GET button. Once downloaded and installed, click on the ... and select **pin to taskbar.

Now, click on the pinned Python logo on the taskbar. This will launch Python IDLE. Now you can run Python programs.

Windows 7, 8 Users

Download the required installer from python official website, and select Download Python 3.x button

Locate the file using Finder, and double-click the package file. Following the installation prompts and instructions.

Be sure to check the box labeled "Add Python to PATH"

Now, open PowerShell in Windows.

Confirm successful installation by checking for Python 3 as shown below:

py -3 -V # Output Python 3.7.2

The Windows installer incorporates pip3 (the Python package manager) by default. You can list installed packages as shown

pip3 list

Note: The installer should set up everything you need for the above command to work. If however, you get a message that Python cannot be found, you may have forgotten to add it to your system path. You can do this by running the installer again, selecting "Modify", and checking the box labeled "Add Python to environment variables" on the second page.

If the problem still persists, set your Python path in Windows manually

Fixing Windows Python Path Not Found

  • Right-click on This PC and click on properties

  • Next, click on the Advanced System settings

  • Finally, click on the ‘Environment variables…

  • That should take you to the Environment Variables screen, where you can add new paths.

  • Click on ‘New…‘ which is located under the User variables box.

  • You should then see a dialog box, which will allow you to add new variables.

  • Before you type any values, you’ll need to locate the relevant Python paths. The paths that you’ll need to get are:

  • The Python application path, which is the folder where you originally installed Python; and

  • The Python Scripts path. The Scripts folder should be located within the Python application path.

  • Now let’s fill the New User Variable box that you saw earlier:

  • For the Variable name, you may type a name, such as ‘Path’ for example.

  • For the Variable value, copy the full Python application path, then use a semicolon (as highlighted in yellow below), and finally copy the Python Scripts path.

  • This is what my Variable value would look like:

  • C:\Users\Nitin\AppData\Local\Programs\Python\Python37-32;C:\Users\Nitin\AppData\Local\Programs\Python\Python37-32\Scripts

  • Press ‘OK’ and you would then see your new Python Path under the ‘User variables' section. Don’t forget to press ‘OK’ again so that the changes will get implemented.

That’s it! You just added Python to the Windows Path.

Did you find this article valuable?

Support Nitin Raturi by becoming a sponsor. Any amount is appreciated!