Installing Python 3


How to Install Python 3 on your Operative System

In this entry we are going to talk about the first step you have to do when you decided to develop using Python, and that is installing Python in your computer, but first keep in mind that since Python is a Programming Language, you can use any text editor to write Python code, but there are more actions to perform when developing, like code testing, debugging and execution. This way Python more than a programming language is a set of tools to produce solutions and applications.

Table of Content

logo

Python is a multiplatform programming language, Python code is executed in an intermediate program called interpreter, and for each platform there is a different way of installing this interpreter among other Python utilities and tools.

From all of the available platforms for Python we are going to focus on the most used, which are the following.

  1. Windows
  2. macOS
  3. Linux

Each of these platforms have different OS versions their own, we are going to focus also on the most recent ones and also we are going to install Python 3, since last year Python 2 has been deprecated by the Python Software Foundation.

Python is a really lightweight development ecosystem, but even though, you have to fullfil some system requirements, we detail them as follow.

  • Processors: Intel® Core™ i5 processor 4300M at 2.60 GHz or 2.59 GHz (1 socket, 2 cores, 2 threads per core)
  • 4 GB of RAM
  • 2 to 3 GB of available disk space

Minimum System Requirements

  • Processors: Intel Atom® processor or Intel® Core™ i3 processor
  • 1 GB of RAM
  • 1 GB of available disk space

Installing Python 3 on Windows

Installing Python 3 on Windows is a simple process, just by following the recipe below for your Windows Platform you will have Python up and running.

Installing Python 3 on Windows 7

Microsoft decided from April 2020 to stop Windows 7 support, but if you find yourself using an old computer with Windows 7 already installed, you still can use the OS and install Python. But there have been some issues with compatibility between the latest versions of Python 3 and Windows 7.

Most of them require for you to upgrade Windows 7 to Service Pack 1, if you already have Service Pack 1 or were able to upgrade using the Windows Update service, you can go to the official Python website and download the installer of the latest version of Python.

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

Downloading Installer

By the time of writing this post Python 3.9.5 was the most recent version.

https://www.python.org/downloads/release/python-395/

At the end of this page you will find the list of available installer, you can choose for both 32-bit or 64-bit.

Then the process of installing Python is executing the installer and following the wizard with recommended settings.

If you do not have Service Pack 1 available for your Windows 7 system then you can download Python 3.7.4, since it is the most recent version with no compatibility issues.

https://www.python.org/downloads/release/python-374/

Installing Python 3 on Windows 10

You can install Python 3 on Windows 10 using the same previous recipe, but the Windows 10 store has Python available for free. You can go to the following address and click the Get button.

https://www.microsoft.com/en-us/p/python-39/9p7qfqmjrfp7

And follow the instructions with recommended settings.

Using a package manager

There are other ways of installing Python in windows, using package managers that can perform software automation.

Installing using Chocolatey

Chocolatey is CLI tool that can be installed following the instructions from the official page.

https://chocolatey.org/install

Even that is not a post about this tool, we briefly say that you can install multiple useful software for development. If you have already installed Chocolatey then you execute the following command in your terminal.

choco install python -y

Installing Python 3 on macOS

Python 3 can be installed on macOS in multiple ways, and in this guide we will give you two on them.

Downloading Installer

You can go to the official download page using your browser.

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

And download the macOS installer of your choice, we recommend to download the following which is a universal installer.

https://www.python.org/ftp/python/3.9.5/python-3.9.5-macos11.pkg

Open the file by double clicking on it and this will execute the Python installer. And just follow the instructions with recommended settings.

Using a package manager

There are other ways of installing Python on macOS, using package managers that can perform software automation.

Installing using Homebrew

Homebrew is CLI tool that can be installed following the instructions from the official page.

https://brew.sh/#install

If you have already installed Homebrew then you execute the following command in your terminal.

brew install python

Installing Python 3 on Linux

Installing Python 3 in Linux has more different ways than Windows, mainly because Linux has so many distributions called distros, and in order to cover a wide range Linux distros in this guide we are explain how to install Python 3 in both, RPM and DEB based Linux, but first let's explain a little about that.

RPM based Linux distros are all those Linux distributions that derive from Red Hat Linux, which include Fedora, CentOS, Suse Linux, Mandriva among others.

DEB based Linux distros are all those linux distributions that derive from Debian, which include Ubuntu, Linux Mint, Kali Linux among others.

Depending on your Linux distro either of these two installing options could work.

Installing Python 3 on Ubuntu

Most of all Linux applications and programs that you install are done via terminal command.

sudo apt install -y python3-pip

Installing Python 3 on Fedora

sudo dnf install python3-pip

Building Python 3 on Linux

Now if you want to perform a advanced installation on any Linux distro, you can download, build and compile Python.

The first step is to install the Python requirements, some packages that Python depends on. You can use your Linux distro package manager to install the dependencies, but here we can give you some examples.

for Ubuntu you can use the following command.

sudo apt-get install build-essential libncursesw5-dev libreadline5-dev libssl-dev libgdbm-dev libc6-dev libsqlite3-dev tk-dev

for Fedora you can use the following command.

yum install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel

In these commands you will find, separated by space each of the required packages in order to install Python 3 on Linux. You can search these packages in your Linux distro package repository and install them using your Linux distro package manager.

Now we have to download the TAR file for Python 3, this file contains all Python 3 source files.

wget https://www.python.org/ftp/python/3.9.5/Python-3.9.5.tar.xz

Then we can unzip and navigate to the Python 3.9.5 directory.

tar -xjf Python-3.9.5.tar.xz cd Python-3.9.5

Finally, we have to execute the following commands.

./configure --prefix=/opt/python3 
make 
sudo make install

This process takes a while to finish, and once is successfully done you will have Python 3 installed in your system.

Verifying your Python Installation

Verifying Python 3 on Windows

Windows terminal is slightly different than Linux and macOS terminals, in order to verify our Python installation we can open a new Windows terminal and execute the following.

python

This will open a new Python REPL (also called Python shell).

Python 3.7.4 (tags/v3.7.4:e09359112e, Jul  8 2019, 20:34:20) [MSC v.1916 64 bit(AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>

In here we can start doing some Python code, but in the first line you can check the detailed version of Python installed in your system. You can quit this shell by invoking the quit built-in method.

quit()

Verifying Python 3 on macOS

We can open a new macOS terminal and execute the following.

python3

This will open a new Python REPL (also called Python shell).

In here we can start doing some Python code, but in the first line you can check the detailed version of Python installed in your system. You can quit this shell by invoking the quit built-in method.

quit()

Verifying Python 3 on Linux

We can open a new Linux terminal and execute the following.

python3

This will open a new Python REPL (also called Python shell).

In here we can start doing some Python code, but in the first line you can check the detailed version of Python installed in your system. You can quit this shell by invoking the quit built-in method.

quit()

Conclusion

Even that Python is a multiplatform programming language, there is no single recipe for installing Python 3 in all of these systems, each system has its own internals so Python needs to adjust its installers to every Operative System, and in each system an standard mode and advanced installation mode.

In later entries we are going to talk about how to run Python in embedded devices and even mobile systems such as Android.

0 Comments

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel