Linux Tactic

Upgrade Your Linux Mint 20: Install Python 39 Today

Installing Python 3.9 on Linux Mint 20: From DeadSnakes PPA Repository or Source Code

Python 3.9, the latest stable release of the popular programming language, offers many new features and improvements, including performance optimizations, better type annotations, and more powerful syntax. If you are a developer or data scientist and want to experiment with the newest version of Python on Linux Mint 20, there are two main methods you can use: installing from the DeadSnakes PPA repository or compiling from the source code.

In this article, we’ll guide you through both methods step by step so you can choose the one that best suits your needs. We’ll assume that you have a fresh, up-to-date installation of Linux Mint 20.

If you need help with that, please consult the official documentation or our previous tutorials. Method 1: Installing Python 3.9 from the DeadSnakes PPA Repository

The DeadSnakes PPA repository is a reliable and trustworthy source that provides pre-built packages of various Python versions for Ubuntu and its derivatives, including Linux Mint.

By adding this repository to your system’s software sources and updating the package cache, you can easily install Python 3.9 and its dependencies with the apt package manager. Step 1: Install Dependencies

Before we can install Python 3.9, we need to ensure that all required dependencies are available.

Open the Terminal application or press Ctrl+Alt+T to launch it, and run the following command:

“`

sudo apt update && sudo apt install -y software-properties-common

“`

This will update the package list and install the software-properties-common package, which provides the necessary tools for managing PPAs.

Step 2: Add PPA Repository

Next, we need to add the DeadSnakes PPA repository to our system. Run the following command:

“`

sudo add-apt-repository ppa:deadsnakes/ppa

“`

You will be asked to confirm the installation and import of the repository’s public key.

Step 3: Install Python 3.9

After adding the PPA repository, you can install Python 3.9 and its associated packages by running the following command:

“`

sudo apt update && sudo apt install -y python3.9

“`

This will download and install Python 3.9 and all its dependencies. Step 4: Verify Python 3.9 Installation

Finally, you can verify that Python 3.9 is installed correctly by running the following command:

“`

python3.9 –version

“`

This should print the version number of Python 3.9, such as:

“`

Python 3.9.0

“`

Method 2: Installing Python 3.9 from the Source Code

Compiling Python 3.9 from the source code requires more advanced skills and knowledge than installing from a package repository.

However, it gives you more control over the installation process and allows you to optimize the binary for your system specifications. Here are the steps involved:

Step 1: Update Apt Repository and Install Dependencies

First, we need to make sure that the system’s apt package manager is up to date and that all required build dependencies are installed.

Run the following command:

“`

sudo apt update && sudo apt upgrade

“`

This will update the package list and install any available updates. Then, install the necessary tools and libraries that are required to build Python from the source.

Run the following command:

“`

sudo apt install -y build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev libsqlite3-dev wget curl llvm

“`

This will install a bunch of packages, including the GCC compiler, various development headers, and libraries that Python depends on. Step 2: Get Python 3.9 Source Code

Next, we need to download the source code for Python 3.9. You can get the latest release from the official website, or download and extract it from the command line using the following commands:

“`

wget https://www.python.org/ftp/python/3.9.0/Python-3.9.0.tgz

tar -xvf Python-3.9.0.tgz

cd Python-3.9.0/

“`

This will download the compressed archive of the source code, extract it to a new directory called `Python-3.9.0`, and change the current working directory to that directory.

Step 3: Run Configure Script

Before we can build and install Python, we need to configure it based on our system’s settings and requirements. Run the following command:

“`

./configure –enable-optimizations –with-ensurepip=install

“`

This will run the `configure` script with some recommended options, such as enabling optimizations for the resulting binary and installing the `pip` package manager.

Note that running the `configure` script may take a few minutes, during which it will check for various dependencies, libraries, and features. Step 4: Compile and Install Python 3.9

After the `configure` script finishes, we can start the actual build process by running the following command:

“`

make -j $(nproc)

sudo make altinstall

“`

This will compile the Python source code into an optimized binary and install it alongside the system’s default Python (usually version 3.x) with the `altinstall` option, which avoids overwriting any system-level files or configurations. Note that the actual compilation time depends on various factors, such as your CPU speed, memory, and disk I/O performance.

You can speed up the process by using the `-j` option with the number of available CPU cores. Step 5: Verify Python 3.9 Installation

Once the installation is complete, you can verify that Python 3.9 is installed and working by running the following command:

“`

python3.9 –version

“`

This should print the version number of Python 3.9, such as:

“`

Python 3.9.0

“`

Conclusion

In this article, we have shown you how to install Python 3.9 on Linux Mint 20 using two methods: from the DeadSnakes PPA repository and from the source code. Both methods have their pros and cons, so choose the one that best suits your needs and preferences.

Now that you have Python 3.9 installed, you can start exploring its new features and improvements and use them to build better software or analyze data. Happy coding!

Python is a widely used programming language for developing various applications, ranging from web development to data science.

The latest stable release of Python, version 3.9, comes with many new features and improvements. This article explains how to install Python 3.9 on Linux Mint 20 using two methods: from a package repository and from the source code.

The first method involves adding the DeadSnakes PPA repository to the system’s software sources and installing Python 3.9 using the apt package manager. This method is straightforward and suitable for most users who want to use the latest version of Python without much hassle.

The second method involves downloading the source code for Python 3.9 and compiling it on the system. This method requires more knowledge and experience, but it gives developers more flexibility and control over how Python is built and optimized for their system’s specifications.

Let’s dive into each method in more detail and see what each step does. Method 1: Installing Python 3.9 from the DeadSnakes PPA Repository

The first method involves using the DeadSnakes PPA (Personal Package Archive) repository, which provides pre-built packages of various Python versions for Ubuntu and its derivatives, including Linux Mint.

To use this repository, we need to follow these steps:

Step 1: Install Dependencies

Before installing Python 3.9, we need to ensure that the required dependencies are installed on the system. This step involves updating the package list and installing the `software-properties-common` package, which provides the tools for managing PPAs.

Step 2: Add PPA Repository

In this step, we add the DeadSnakes PPA repository to the system’s software sources.

This step involves running the `sudo add-apt-repository` command, which adds the PPA repository and imports its public key for authentication. Step 3: Install Python 3.9

Once the PPA repository is added, we can install Python 3.9 and its required packages by running the `sudo apt update` and `sudo apt install -y python3.9` commands.

This step installs Python 3.9 and all its dependencies. Step 4: Verify Python 3.9 Installation

Finally, we can verify that Python 3.9 is installed correctly by running the `python3.9 –version` command, which should print the installed version number.

Method 2: Installing Python 3.9 from the Source Code

The second method involves downloading the source code for Python 3.9 from the official website or other reliable sources and compiling it on the system. This method requires more advanced skills and knowledge than the first method but gives developers more flexibility and control over the build process.

The following steps are involved:

Step 1: Install Dependencies

Before we can compile Python 3.9 from source, we need to ensure that the required build dependencies are available on the system. This step involves updating the package list and installing various development headers and libraries that Python depends on.

Step 2: Get Python 3.9 Source Code

In this step, we download the source code for Python 3.9 from the official website or other trusted sources. This step involves using the `wget` or `curl` command to download the compressed archive of the source code and the `tar` command to extract the contents to a new directory.

Step 3: Run Configure Script

Before we can build Python from the source, we need to run the `configure` script, which checks for various dependencies, libraries, and features on the system and sets up the build environment. This step involves running the `./configure` command with some recommended options, such as enabling optimizations and installing `pip`.

Step 4: Compile and Install Python 3.9

Once the `configure` script finishes running, we can start the actual build process by running the `make` command, which compiles the source code into an optimized binary. This step may take some time, depending on the system’s specifications.

After the compilation is complete, we can install Python 3.9 alongside the default Python installation by running the `

sudo make altinstall` command. Step 5: Verify Python 3.9 Installation

Finally, we can verify that Python 3.9 is installed correctly by running the `python3.9 –version` command, which should print the installed version number.

Conclusion

In conclusion, installing Python 3.9 on Linux Mint 20 is a straightforward process that can be done using either a package repository or source code compilation. Both methods have their advantages and disadvantages, but they allow developers to use the latest version of Python and take advantage of its new features and improvements.

The first method is suitable for most users who want to use Python 3.9 quickly and efficiently, while the second method is suitable for advanced users who want more flexibility and control over the build process. I hope this article has been helpful in guiding you through the installation process, and you can now enjoy using Python 3.9 on your Linux Mint 20 system.

In summary, this article has provided two methods for installing Python 3.9 on Linux Mint 20: installing from the DeadSnakes PPA repository or compiling from the source code. The first method is suitable for most users who want to use Python 3.9 quickly and efficiently, while the second method is suitable for advanced users who want more flexibility and control over the build process.

Both methods have their advantages and disadvantages, and it’s up to the user to choose the one that best fits their needs. Regardless of the method chosen, Python 3.9 offers many new features and improvements that are worth exploring, making it an essential tool for developers and data scientists alike.

Popular Posts