Oct 13, 2023 5 min read

How to Install Python 3.7 on Debian 10

Install Python 3.7 on Debian 10 with our step-by-step tutorial. It is a popular programming language known for its simplicity and readability.

Install Python 3.7 on Debian 10
Table of Contents

Choose a different version or distribution

Introduction

Before we begin talking about how to install Python 3.7 on Debian 10, let's briefly understand – What is Python?

Python is a popular and versatile programming language known for its simplicity and readability. Debian 10 comes with Python 3.7 pre-installed, but if you need to install a specific version or want to utilize the latest features in Python 3.7.

In this tutorial, you will install Python 3.7 on Debian 10. We will also address a few FAQs on how to install Python 3.7 on Debian 10.

Advantages

  1. Easy to learn: Python's syntax is easy to read and understand, making it a great language for beginners.
  2. Versatile: Python can be used for a wide range of applications, from web development to scientific computing.
  3. Large community: Python has a large and active community of developers, which means there are plenty of resources available online to help you learn and solve problems.
  4. Plenty of libraries: Python has a vast collection of libraries and modules, making it easy to perform complex tasks with minimal coding.
  5. Cross-platform: Python is available for multiple platforms, including Windows, macOS, and Linux, so you can write code on one platform and run it on another.

Update Debian to Install Python 3.7

Run a quick update before you start to make sure your system is updated to prevent conflicts during the tutorial and to practice proper system maintenance.

sudo apt update && sudo apt upgrade

Install Python 3.7

Download Python 3.7

Use the wget command to download the Python 3.7 archive once you have the download link.

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

The Python archive should be extracted. If you downloaded a newer version, don't forget to update the version number:

tar -xf Python-3.7.{version}.tar.xz

You can optionally transfer Python 3.7 to a suitable location, such as the /opt/ directory.

sudo mv Python-3.7.{version} /opt/

Next, install the dependencies necessary to install Python 3.7.

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

Go to the directory

cd /opt/Python-3.7.{version}/

Execute the command ./configure -enable-optimizations.

./configure --enable-optimizations --enable-shared

Please take note that the script does a number of checks to ensure that all of your system's dependencies are present. The ./configure -enable-optimizations command will run numerous tests to optimize the Python binary, slowing down the build process.

It's time to compile the environment using the make command now that you have built and configured it.

make

If you have a powerful server, a useful tip is to specify the -j <number of cpu> as this can considerably enhance compiling speed. For instance, the VegaStack machine has 6 CPUs, and you can use all 6, or at the very least 4 to 5, to boost the speed.

make -j 6

Install Python binaries as shown below once the building is complete:

sudo make altinstall

Note, it’s recommended to use the make altinstall command NOT to supersede the default Python 3 binary system.

After the installation, you should set up the dynamic linker run-time bindings:

sudo ldconfig /opt/Python3.7.{version}

Please take note to not omit this, or problems will arise. You must also substitute the path with your directory name and version.

By executing the following command, you can verify that Python 3.7 and the build version are both installed:

python3.7 --version

Create a Virtual Environment

The Python venv module is a virtual environment within the Python environment. It has a separate Python interpreter, libraries, and scripts from those established in other virtual environments. Any libraries you have installed on your operating system, such as those on your Debian system, should avoid interfering with your production environments and causing disruptions.

Create a simple Python project to check that Python 3.7 is installed and working properly.

Create the project directory first, then navigate there.

mkdir ~/test_app && cd ~/test_app

Run the following command within the project root directory to create a virtual environment for the test name test_app.

python3.7 -m venv test_app_venv

Next, enable the virtual environment as follows:

source test_app_venv/bin/activate

Now that the virtual environment has started, you are in the shell prompt terminal. This displays the environment's name that will be prefixed.

To leave the virtual environment, enter the following command:

deactivate

Install Python PIP 3.7

PIP 3.7 should be installed by default. Manually installing the package manager is another approach for PIP issues.

There are various methods for doing this. Here is one of the most widely used approaches.

Re-enter your environment and use the wget command to download get-pip.py.

wget https://bootstrap.pypa.io/get-pip.py

Install the downloaded file next.

python3.7 get-pip.py

It is a good idea to look for updates after installation.

python3.7 -m pip install --upgrade pip

With the following command, you can now confirm that PIP 3.7 version is actually installed.

pip3.7 --version

FAQs to Install Python 3.7 on Debian 10

Why install Python 3.7 on Debian 10? 

Debian 10 comes with Python 3.7 pre-installed, but if you need to install a specific version or if you want to utilize the latest features in Python 3.7, you can follow this guide to install it manually.

What are the prerequisites for installing Python 3.7 on Debian 10? 

To install Python 3.7 on Debian 10, you need administrative access to the Debian system and a working internet connection.

How do I install Python 3.7 on Debian 10? 

To install Python 3.7 on Debian 10, you can use the deadsnakes PPA repository, which provides pre-built packages for different Python versions. The installation process involves adding the repository, updating the package lists, and installing Python 3.7 using apt-get or apt.

Can I have multiple Python versions installed on Debian 10? 

Yes, it is possible to have multiple Python versions installed on Debian 10. By default, Debian 10 includes Python 3.7, so installing Python 3.7 alongside it will allow you to access both versions.

What are the advantages of using Python 3.7? 

Python 3.7 introduces several improvements and new features, including optimized performance, better syntax, new built-in modules, enhanced libraries, and updated methodologies.

How can I manage Python packages and dependencies in Python 3.7? 

Python provides the pip package manager, which allows you to install, upgrade, and manage Python packages and their dependencies.

Why install Python 3.7 on Debian 10 when it already comes with Python 3.7 pre-installed? 

While Debian 10 includes Python 3.7 by default, you may need to install it manually to ensure you have the latest version or to manage multiple Python versions on your system. Installing Python 3.7 separately allows you to have more control over your Python environment and access the latest features and enhancements specific to Python 3.7.

Conclusion

Installing Python 3.7 on Debian 10 allows you to take advantage of the latest features and enhancements introduced in Python. With improved performance, syntax enhancements, new modules, and security features, Python 3.7 offers an enhanced programming experience.

By following the steps in this tutorial, you should be able to install Python 3.7 on your system with ease. Don't forget to keep your system up to date and use the latest version of Python for the best performance and security.

If you have any queries, please leave a comment below and we’ll be happy to respond to them.

Great! You’ve successfully signed up.
Welcome back! You've successfully signed in.
You've successfully subscribed to DevOps Tutorials - VegaStack.
Your link has expired.
Success! Check your email for magic link to sign-in.
Success! Your billing info has been updated.
Your billing was not updated.