Python is a popular high-level object-oriented programming language that is open-source and has a large community. Its popularity grows...
Python is a popular high-level object-oriented programming language that is open-source and has a large community. Its popularity grows as a result of its simplicity and easy-to-understand grammar. Python can be used to create a wide range of applications, from basic scripts to sophisticated machine learning algorithms.
Python 3.10 is the most recent release version, however it is not as stable as Python 3.9. However, the final candidate is likely to be released soon. The following features are included in Python 3.10:
- Ability to directly type hint lists and dictionaries.
- Decorators who are more adaptable
- Deprecated compatibility code has been removed.
- A Python parser with more power.
- HTTP status codes have been updated.
- Support for the correct time zone.
- Updates on security, etc.
The following are some of Python's most common applications:
- Workflows are created using this tool in conjunction with applications.
- Used to construct web apps on a server.
- Rapid prototyping or development of production-ready software.
- Handle large amounts of data and execute sophisticated calculations.
- Read and edit files via connecting to database systems.
This tutorial will show you how to install Python 3.10 on Ubuntu 18.04 or 20.04 systems. I'll show you how to install Python 3.10 on your Debian 11|10 machine using two different techniques.
- Install Python 3.10 from the deadsnakes PPA
- Manually build Python 3.10 from the source code
The First Steps
Make sure your system is up to date and that you have all of the necessary programmes loaded.
sudo apt update && sudo apt upgrade -yOption 1: Using the Apt Repo, install Python 3.10 on Ubuntu 18.04 or 20.04
Installing Python 3.10 with APT on Ubuntu 18.04 or 20.04 is a breeze, thanks to the deadsnakes custom PPA! This makes it simple to set up Python on Ubuntu and receive regular updates, bug fixes, and security patches.
To add custom PPAs, you'll need to install the required requirement.
sudo apt install software-properties-common -yThen, as shown below, add the deadsnakes PPA to your APT package management sources list.
sudo add-apt-repository ppa:deadsnakes/ppaPress Enter to continue.
..........
To install 3rd-party Python modules, you should use the common Python packaging tools. For an introduction into the Python packaging ecosystem and its tools, refer to the Python Packaging User Guide:
https://packaging.python.org/installing/
Sources
=======
The package sources are available at:
https://github.com/deadsnakes/
Nightly Builds
==============
For nightly builds, see ppa:deadsnakes/nightly https://launchpad.net/~deadsnakes/+archive/ubuntu/nightly
More info: https://launchpad.net/~deadsnakes/+archive/ubuntu/ppa
Press [ENTER] to continue or ctrl-c to cancel adding it
With the deadsnakes repository added to your Ubuntu 18.04 or 20.04 system, now download Python 3.10 with the single command below.
sudo apt install python3.10Dependency Tree:
...................
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
libpython3.10-minimal libpython3.10-stdlib python3.10-minimal
Suggested packages:
python3.10-venv binfmt-support
The following NEW packages will be installed:
libpython3.10-minimal libpython3.10-stdlib python3.10 python3.10-minimal
0 upgraded, 4 newly installed, 0 to remove and 192 not upgraded.
Need to get 5,023 kB of archives.
After this operation, 19.7 MB of additional disk space will be used.
Do you want to continue? [Y/n] yVerify the installation by checking the installed version.
$ python3.10 --version
3.10.0Option 2 – Install Python 3.10 on Ubuntu 18.04 or 20.04 from Source.
Another option for installing Python 3.10 on your Ubuntu 18.04 or 20.04 machine is to compile it from source code. You will get the newest Python version using this installation technique, but you will not be able to receive ongoing updates, bug fixes, or security upgrades through the APT package management.
To build Python 3.10 from the source code, you'll need to install the necessary dependencies.
sudo apt update
sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev libsqlite3-dev wget libbz2-devNow go to the Python official release page and download the most recent version of Python. Alternatively, copy the Python 3.10 gzipped tarball download link and use Wget to pull it as shown below.
wget https://www.python.org/ftp/python/3.10.0/Python-3.10.0.tgzAfter you've downloaded this file, you'll need to extract it.
tar -xf Python-3.10.*.tgzNow go to the extracted directory and execute the configure script to verify that all of the essential dependencies are present. Using the –-enable optimization flag, the binary is optimised by running numerous tests.
cd Python-3.10.*/
./configure --enable-optimizationsOutput:
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking for python3.10... no
checking for python3... python3
checking for --enable-universalsdk... no
checking for --with-universal-archs... no
checking MACHDEP... "linux"
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
.....................
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
creating Modules/Setup.local
creating MakefileNow initiate the Python 3.10 build process as below.
cd Python-3.10.*/
./configure --enable-optimizationsOutput:
make -j 4To make the process go faster, make sure the -j parameter matches the number of cores on your system. Using the command nproc, you may find out how many cores your machine has. In this case, my computer has two cores.
Sample Output:
....................
The following modules found by detect_modules() in setup.py, have been
built by the Makefile instead, as configured by the Setup files:
_abc pwd time
running build_scripts
copying and adjusting /home/ubuntu/Python-3.10.0/Tools/scripts/pydoc3 -> build/scripts-3.10
copying and adjusting /home/ubuntu/Python-3.10.0/Tools/scripts/idle3 -> build/scripts-3.10
copying and adjusting /home/ubuntu/Python-3.10.0/Tools/scripts/2to3 -> build/scripts-3.10
changing mode of build/scripts-3.10/pydoc3 from 644 to 755
changing mode of build/scripts-3.10/idle3 from 644 to 755
changing mode of build/scripts-3.10/2to3 from 644 to 755
renaming build/scripts-3.10/pydoc3 to build/scripts-3.10/pydoc3.10
renaming build/scripts-3.10/idle3 to build/scripts-3.10/idle3.10
renaming build/scripts-3.10/2to3 to build/scripts-3.10/2to3-3.10
make[1]: Leaving directory '/home/ubuntu/Python-3.10.0'After the build is finished, run the make command to install Python 3.10 on Ubuntu 18.04 or 20.04.
sudo make altinstallHere altinstall is used instead of install in order to keep the default Python binary path in /usr/bin/python.
Sample Output:
Looking in links: /tmp/tmpwbk6rtev
Processing /tmp/tmpwbk6rtev/setuptools-57.4.0-py3-none-any.whl
Processing /tmp/tmpwbk6rtev/pip-21.2.3-py3-none-any.whl
Installing collected packages: setuptools, pip
WARNING: Value for scheme.headers does not match. Please report this to <https://github.com/pypa/pip/issues/10151>
distutils: /usr/local/include/python3.10/setuptools
sysconfig: /home/ubuntu/Python-3.10.0/Include/setuptools
WARNING: Value for scheme.headers does not match. Please report this to <https://github.com/pypa/pip/issues/10151>
distutils: /usr/local/include/python3.10/pip
sysconfig: /home/ubuntu/Python-3.10.0/Include/pip
Successfully installed pip-21.2.3 setuptools-57.4.0
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venvVerify your installation.
$ python3.10 --version
Python 3.10.0On Ubuntu 18.04 or 20.04, install Python Modules|Extensions.
Python modules and extensions are useful because they provide functionality to the language. The Python Package Manager can be used to install modules on Ubuntu 18.04 or 20.04. (PIP). PIP must be installed on your system as described here.
sudo apt install python3-pipThen use the syntax below to install a Python module of choice.
sudo pip install module-nameIn this guide, I will demonstrate how to install a Python module beautifulsoup4.
sudo pip install beautifulsoup4Output:
Collecting beautifulsoup4
Downloading beautifulsoup4-4.10.0-py3-none-any.whl (97 kB)
|████████████████████████████████| 97 kB 259 kB/s
Collecting soupsieve>1.2
Downloading soupsieve-2.2.1-py3-none-any.whl (33 kB)
Installing collected packages: soupsieve, beautifulsoup4
Successfully installed beautifulsoup4-4.10.0 soupsieve-2.2.1You can list locally installed Python packages using the command:
$ pip list
Package Version
---------------------- --------------------
attrs 19.3.0
Automat 0.8.0
beautifulsoup4 4.10.0
blinker 1.4
certifi 2019.11.28
chardet 3.0.4
Click 7.0
cloud-init 20.2
colorama 0.4.3
command-not-found 0.3
configobj 5.0.6
constantly 15.1.0
cryptography 2.8
dbus-python 1.2.16
distro 1.4.0
distro-info 0.23ubuntu1
entrypoints 0.3
httplib2 0.14.0
hyperlink 19.0.0
..............That concludes the discussion. I hope you found my tutorial on installing Python 3.10 on Ubuntu 18.04 or 20.04 useful. You're now ready to utilise Python to create online apps, software, and workflows, among other things.
COMMENTS