Sunday, December 29, 2024
Google search engine
HomeGuest BlogsInstall Python 3.9 on Debian 11 / Debian 10

Install Python 3.9 on Debian 11 / Debian 10

.tdi_3.td-a-rec{text-align:center}.tdi_3 .td-element-style{z-index:-1}.tdi_3.td-a-rec-img{text-align:left}.tdi_3.td-a-rec-img img{margin:0 auto 0 0}@media(max-width:767px){.tdi_3.td-a-rec-img{text-align:center}}

Python is a programming and scripting language developed under an OSI-approved open source license, making it freely usable and distributable, even for commercial use. The management and control of the development is under the Python Software Foundation. As of this article update the latest release of the Python is 3.9.x. We will demonstrate how Linux users can install Python 3.9 on Debian 11 / Debian 10 system.

Python is an easy to learn language, with clean and simple syntax making it quick choice to new and experienced developers. Python can be used to build Desktop applications, automation scripts, Web applications, Games, Big data applications among many others. The first step in Python development journey is the software installation.

Install Python 3.9 on Debian 11 / Debian 10

Update your APT cache index before installation of Python 3.9 on Debian 10 system.

.tdi_2.td-a-rec{text-align:center}.tdi_2 .td-element-style{z-index:-1}.tdi_2.td-a-rec-img{text-align:left}.tdi_2.td-a-rec-img img{margin:0 auto 0 0}@media(max-width:767px){.tdi_2.td-a-rec-img{text-align:center}}

sudo apt update

If upgrade is possible then run the commands below.

sudo apt upgrade -y

Then restart the system after a successful upgrade.

sudo reboot

After the system is rebooted, install dependency packages:

sudo apt install wget software-properties-common build-essential libnss3-dev zlib1g-dev libgdbm-dev libncurses5-dev   libssl-dev libffi-dev libreadline-dev libsqlite3-dev libbz2-dev

Hit the y key to begin installation:

0 upgraded, 95 newly installed, 0 to remove and 0 not upgraded.
Need to get 74.7 MB of archives.
After this operation, 296 MB of additional disk space will be used.
Do you want to continue? [Y/n] y

Visit Python Downloads page and pull the latest release.

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

Extract the downloaded file.

tar xvf Python-3.9.16.tgz

Change working directory to create Python folder:

cd Python-*/

Run configuration command

./configure --enable-optimizations

Sample output:

....
checking for shm_open... yes
checking for shm_unlink... yes
checking for pkg-config... no
checking for openssl/ssl.h in /usr/local/ssl... no
checking for openssl/ssl.h in /usr/lib/ssl... no
checking for openssl/ssl.h in /usr/ssl... no
checking for openssl/ssl.h in /usr/pkg... no
checking for openssl/ssl.h in /usr/local... no
checking for openssl/ssl.h in /usr... no
checking whether compiling and linking against OpenSSL works... no
checking for --with-ssl-default-suites... python
checking for --with-builtin-hashlib-hashes... md5,sha1,sha256,sha512,sha3,blake2
configure: creating ./config.status
config.status: creating Makefile.pre
config.status: creating Misc/python.pc
config.status: creating Misc/python-embed.pc
config.status: creating Misc/python-config.sh
config.status: creating Modules/ld_so_aix
config.status: creating pyconfig.h
config.status: pyconfig.h is unchanged
creating Modules/Setup.local
creating Makefile

Build Python 3.9 on Debian 11 / Debian 10 Linux:

sudo make altinstall

A successful installation will have output similar to below:

....
changing mode of /usr/local/lib/python3.9/lib-dynload/__pycache__ to 755
running install_scripts
copying build/scripts-3.9/idle3.9 -> /usr/local/bin
copying build/scripts-3.9/pydoc3.9 -> /usr/local/bin
copying build/scripts-3.9/2to3-3.9 -> /usr/local/bin
changing mode of /usr/local/bin/idle3.9 to 755
changing mode of /usr/local/bin/pydoc3.9 to 755
changing mode of /usr/local/bin/2to3-3.9 to 755
rm /usr/local/lib/python3.9/lib-dynload/_sysconfigdata__linux_x86_64-linux-gnu.py
rm -r /usr/local/lib/python3.9/lib-dynload/__pycache__
/usr/bin/install -c -m 644 ./Misc/python.man \
	/usr/local/share/man/man1/python3.9.16
if test "xupgrade" != "xno"  ; then \
	case upgrade in \
		upgrade) ensurepip="--altinstall --upgrade" ;; \
		install|*) ensurepip="--altinstall" ;; \
	esac; \
	 ./python -E -m ensurepip \
		$ensurepip --root=/ ; \
fi
Looking in links: /tmp/tmpog4qrruc
Requirement already up-to-date: setuptools in /usr/local/lib/python3.9/site-packages (49.2.1)
Requirement already up-to-date: pip in /usr/local/lib/python3.9/site-packages (20.2.3)

Running the commands below will output the version of Python 3.9 available in your system:

$ python3.9 --version
Python 3.9.16

Upgrade pip

$ /usr/local/bin/python3.9 -m pip install --upgrade pip
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: pip in /usr/local/lib/python3.9/site-packages (21.2.4)
Collecting pip
  Downloading pip-21.3.1-py3-none-any.whl (1.7 MB)
     |████████████████████████████████| 1.7 MB 11.1 MB/s
Installing collected packages: pip
Successfully installed pip-21.3.1

To install Python modules available in modules releases page, use the command syntax:

python3.9 -m pip install <module>

Use Python 3.9 shell

$ python3.9
Python 3.9.16 (default, Aug 16 2021, 07:47:40)
[GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.

Print hello world message to confirm it is working:

>>> print("Hello World")
Hello World

Close Python interactive shell session

>>> exit()

Conclusion

In this short guide we’ve shown you how to install Python 3.9 on Debian 11 / Debian 10 Linux. If you’re using this guide at a later date in time, a similar process applies.

Python Programing Books:

You can check other articles in our website on Debian 10 system management:

.tdi_4.td-a-rec{text-align:center}.tdi_4 .td-element-style{z-index:-1}.tdi_4.td-a-rec-img{text-align:left}.tdi_4.td-a-rec-img img{margin:0 auto 0 0}@media(max-width:767px){.tdi_4.td-a-rec-img{text-align:center}}

RELATED ARTICLES

Most Popular

Recent Comments