Completely install Python 3.8 version software on Debian 10 system

888u

Last update at :2024-05-21,Edit by888u

Python is one of the most widely used programming languages ​​in the world. Python syntax is simple and easy to learn, making it a popular choice among beginners and experienced developers alike. Python is a very general programming language. Nowadays, we have a lot of algorithm software and crawlers that use Python programs. In fact, we can't say which language is the best. We can only say that the functional requirements are different, so different programs have different use areas.

By default, our Debian 10 includes Python version 3.7, which can be installed or updated using the apt tool. However, some of our programs require the latest Python 3.8, which is the latest major version of the Python language. It includes many new features such as assignment expressions, positional parameters only, f-string support, and more. This tutorial explains how to install Python 3.8 on Debian 10.

First, install Python 3.8 based on Debian 10

Building Python 3.8 on Debian is a relatively simple process that only takes a few minutes.

1. First install the packages required to build Python source code:

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

2. Use wget or curl to download the latest version of the source code from the Python download page.

curl -O https://www.python.org/ftp/python/3.8.2/Python-3.8.2.tar.xz

Here, we install version 3.8.2. We can check which is the latest version from the official.

3. Unzip the compressed package

tar -xf Python-3.8.2.tar.xz

4. Enter the directory to run the installation

cd Python-3.8.2
./configure --enable-optimizations

Run make to prepare for compilation

make -j 4

Modify -j to correspond to the number of cores in the processor. You can find this number by typing nproc.

5. After the build is complete, run the following command as a user with sudo access to install Python:

sudo make altinstall

Do not use the standard make install as it will overwrite the default system python3 files.

6. At this point, Python 3.8 has been installed on your Debian system and we can use it. We can verify this by typing:

python3.8 --version

Second, create a virtual environment

A Python virtual environment is a self-contained directory tree that includes a Python installation and additional packages. It allows us to install Python modules in an isolated location for a specific project instead of installing them globally. This way, we don't have to worry about affecting other Python projects.

In this example, we will create a new Python 3.8 project named my_app in the user's home directory.

First, create the project directory and change to it:

mkdir ~/my_app && cd ~/my_app

Run the following command from the project root to create a virtual environment named my_app_venv:

python3.8 -m venv my_app_venv

Activate the environment

source my_app_venv/bin/activate

When activated, the shell prompt will be prefixed with the environment name. Starting with Python 3.4, Python's package manager is installed by default when creating a virtual environment pip. In a virtual environment, you can use pip instead of pip3.8 and python instead of python3.8:

python -v

In this way, we can directly see the python3.8 version by default.

Is it very easy to install Python 3.8 in Debian10?

Recommended site searches: free asp space, how to check ip, ip query network, foreign vps server rental, Hong Kong server, domain name information query, website ip address query server in the United States, domain name registration official website, Taiwan host,

Completely install Python 3.8 version software on Debian 10 system

All copyrights belong to 888u unless special state
取消
微信二维码
微信二维码
支付宝二维码