{"id":131488,"date":"2025-10-24T19:58:57","date_gmt":"2025-10-24T16:58:57","guid":{"rendered":"https:\/\/computingforgeeks.com\/?p=131488"},"modified":"2026-03-21T19:04:24","modified_gmt":"2026-03-21T16:04:24","slug":"how-to-install-python-on-ubuntu-linux","status":"publish","type":"post","link":"https:\/\/computingforgeeks.com\/how-to-install-python-on-ubuntu-linux\/","title":{"rendered":"How To Install Python 3.11 on Ubuntu 22.04|20.04|18.04"},"content":{"rendered":"\n<p>Programming plays a huge role in the tech world. Without it, you wouldn&#8217;t be able to view this article or use your phone, computer, smart TV etc. In this technology-driven world, learning programming can really give you a competitive edge. This can help innovate and create solutions for the global society.<\/p>\n\n\n\n<p>Programming can be defined as a set of instructions given to a computer to execute. These instructions are written in language that the computer understands. Today there are many programming languages, the most common ones are Java, JavaScript, Ruby, Python, C\/C++, Swift e.t.c.<\/p>\n\n\n\n<p><strong>Python<\/strong> is an open-source, high-level object-oriented programming language with a large community. It is one of the most considered languages for beginners. This is mainly because of its simplicity and easy-to-learn syntax. It is used to build a wide range of applications from small and simple scripts to complex machine-learning algorithms. Python is mainly used for:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Rapid prototyping or production-ready software development.<\/li>\n\n\n\n<li>Create web applications on servers<\/li>\n\n\n\n<li>Handling big data and performing complex mathematics.<\/li>\n\n\n\n<li>Connect to database systems, read and modify files.<\/li>\n\n\n\n<li>Alongside software to create workflows<\/li>\n<\/ul>\n\n\n<p>[ebook product=&#8221;2&#8243; theme=&#8221;dark&#8221;]<\/p>\n\n\n\n<p>The latest release of Python is <strong>Python 3.11<\/strong> made on October 24, 2022. This faster and more user-friendly version has been made available after seventeen months of development. This has resulted in several features and improvements being tagged to it.<\/p>\n\n\n\n<p>The main features associated with Python 3.11 are:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Faster code execution due to considerable effort in the Faster CPython project<\/li>\n\n\n\n<li>Better error messages with more informative tracebacks<\/li>\n\n\n\n<li>Task and exception groups that simplify working with asynchronous code<\/li>\n\n\n\n<li>Native TOML support for working with configuration files<\/li>\n\n\n\n<li>Several new typing features that improve Python\u2019s static typing support<\/li>\n\n\n\n<li>A More powerful Python parser<\/li>\n\n\n\n<li>Security updates.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Install Python 3.11 on Ubuntu 22.04 or 20.04 or 18.04<\/h2>\n\n\n\n<p>This guide demonstrates how to install Python 3.11 on Ubuntu Linux machine.<\/p>\n\n\n\n<p>This guide will provide two methods to get Python 3.11 installed on Ubuntu. The two methods are:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Installing from the&nbsp;<strong>deadsnakes PPA<\/strong><\/li>\n\n\n\n<li>Manually build Python 3.11 from the&nbsp;<strong>source code<\/strong><\/li>\n<\/ul>\n\n\n\n<p>But before we proceed, ensure that the system packages are updated to their latest available versions:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt update &amp;&amp; sudo apt upgrade -y<\/code><\/pre>\n\n\n\n<p>Now choose one of the method that best works for you.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Method 1 &#8211; Install from&nbsp;deadsnakes PPA<\/h3>\n\n\n\n<p>The deadsnakes PPA provides the simplest method to install Python 3.11 on Ubuntu. It also enables users to receive continued updates, bug fixes, and security updates. A big thumbs up to this custom PPA!<\/p>\n\n\n\n<p>First, install the required dependency packages:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt install software-properties-common -y<\/code><\/pre>\n\n\n\n<p>Add the deadsnakes PPA to the APT package manager sources list.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo add-apt-repository ppa:deadsnakes\/ppa<\/code><\/pre>\n\n\n\n<p>Proceed as shown:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>..........\nTo 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:\nhttps:&#47;&#47;packaging.python.org\/installing\/\n\nSources\n=======\nThe package sources are available at:\nhttps:\/\/github.com\/deadsnakes\/\n\nNightly Builds\n==============\n\nFor nightly builds, see ppa:deadsnakes\/nightly https:\/\/launchpad.net\/~deadsnakes\/+archive\/ubuntu\/nightly\n More info: https:\/\/launchpad.net\/~deadsnakes\/+archive\/ubuntu\/ppa\nPress &#91;ENTER] to continue or ctrl-c to cancel adding it<\/code><\/pre>\n\n\n\n<p>Press Enter to continue. Once the PPA has been added, you can install Python 3.11 on Ubuntu using the commands:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt install python3.11<\/code><\/pre>\n\n\n\n<p>Verify the installation:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-pink-color\">python3.11 --version<\/mark>\nPython 3.11.4<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Method 2 &#8211; Install from source<\/h3>\n\n\n\n<p>This is an alternative method of installing Python 3.11 on Ubuntu Linux system. With this method, you are guaranteed the latest Python Version. The only problem with this method is that you will not be able to receive continued updates, bug fixes, and security updates through the APT package manager.<\/p>\n\n\n\n<p>Begin by installing the packages required to build Python 3.11 from the source.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt update &amp;&amp; sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev libsqlite3-dev wget libbz2-dev pkg-config -y<\/code><\/pre>\n\n\n\n<p>Once the packages have been installed, download the latest available Python 3.11 gzipped tarball from the<a href=\"https:\/\/www.python.org\/downloads\/source\/\" target=\"_blank\" rel=\"noreferrer noopener\"> Python official release page<\/a>.<\/p>\n\n\n\n<p>You can still download the tarball using wget:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>wget https:\/\/www.python.org\/ftp\/python\/3.11.9\/Python-3.11.9.tgz<\/code><\/pre>\n\n\n\n<p>Extract the downloaded archive:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>tar -xf Python-3.11.*.tgz<\/code><\/pre>\n\n\n\n<p>Now navigate into the directory:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cd Python-3.11.*\/<\/code><\/pre>\n\n\n\n<p>We will check if the required dependencies are met and optimize the binary with the command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.\/configure --enable-optimizations<\/code><\/pre>\n\n\n\n<p>Sample Output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>checking build system type... x86_64-pc-linux-gnu\nchecking host system type... x86_64-pc-linux-gnu\nchecking for Python interpreter freezing... .\/_bootstrap_python\nchecking for python3.11... no\nchecking for python3.10... no\nchecking for python3.9... no\nchecking for python3.8... python3.8\nchecking Python for regen version... Python 3.8.10\nchecking for pkg-config... \/usr\/bin\/pkg-config\nchecking pkg-config is at least version 0.9.0... yes\nchecking for --enable-universalsdk... no\nchecking for --with-universal-archs... no\nchecking MACHDEP... \"linux\"\nchecking for gcc... gcc\n.....\nconfigure: creating .\/config.status\nconfig.status: creating Makefile.pre\nconfig.status: creating Misc\/python.pc\nconfig.status: creating Misc\/python-embed.pc\nconfig.status: creating Misc\/python-config.sh\nconfig.status: creating Modules\/Setup.bootstrap\nconfig.status: creating Modules\/Setup.stdlib\nconfig.status: creating Modules\/ld_so_aix\nconfig.status: creating pyconfig.h\nconfigure: creating Modules\/Setup.local\nconfigure: creating Makefile<\/code><\/pre>\n\n\n\n<p>Once checked, start the build process with the command below. We have used<strong><em> -j<\/em><\/strong> to provide the number of cores available on the system, this makes the build process faster:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>make -j $(nproc)<\/code><\/pre>\n\n\n\n<p>Sample Output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>........\ncopying and adjusting \/home\/ubuntu\/Python-3.11.4\/Tools\/scripts\/idle3 -&gt; build\/scripts-3.11\ncopying and adjusting \/home\/ubuntu\/Python-3.11.4\/Tools\/scripts\/2to3 -&gt; build\/scripts-3.11\nchanging mode of build\/scripts-3.11\/pydoc3 from 664 to 775\nchanging mode of build\/scripts-3.11\/idle3 from 664 to 775\nchanging mode of build\/scripts-3.11\/2to3 from 664 to 775\nrenaming build\/scripts-3.11\/pydoc3 to build\/scripts-3.11\/pydoc3.11\nrenaming build\/scripts-3.11\/idle3 to build\/scripts-3.11\/idle3.11\nrenaming build\/scripts-3.11\/2to3 to build\/scripts-3.11\/2to3-3.11\ngcc -pthread -c -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall    -fno-semantic-interposition -std=c11 -Objects\/moduleobject.o Objects\/namespaceobject.o Objects\/object.o Objects\/obmalloc.o Objects\/picklebufobject.o Objects\/rangeobject.o Objects\/setobject.o Objects\/sliceobject.o Objects\/structseq.o Objects\/tupleobject.o Objects\/typeobject.o Objects\/unicodeobject.o Objects\/unicodectype.o Objects\/unionobject.o Objects\/weakrefobject.o Python\/_warnings.o Python\/Python-ast.o Python\/Python-tokenize.o Python\/asdl.o Python\/ast.o Python\/ast_opt.o Python\/ast_unparse.o Python\/bltinmodule.o Python\/ceval.o Python\/codecs.o Python\/compile.o Python\/context.o Python\/dynamic_annotations.o Python\/errors.o Python\/frame.o Python\/frozenmain.o Python\/future.o Python\/getargs.o Python\/getcompiler.o Python\/getcopyright.o Python\/getplatform.o  Modules\/timemodule.o  Modules\/_weakref.o  Modules\/_abc.o  Modules\/_functoolsmodule.o  Modules\/_localemodule.o  Modules\/_operator.o  Modules\/_stat.o  Modules\/symtablemodule.o  Modules\/pwdmodule.o  Modules\/xxsubtype.o Python\/deepfreeze\/deepfreeze.o Modules\/getpath.o Python\/frozen.o -lpthread -ldl  -lutil                        -lm \nmake&#91;1]: Leaving directory '\/home\/ubuntu\/Python-3.11.4'<\/code><\/pre>\n\n\n\n<p><strong><em>Note<\/em><\/strong>: Building Python from source can take a long time, depending on your system. You can adjust the number passed to the <code>-j<\/code> option in the <code>make<\/code> command to specify the number of parallel build jobs to run, which can speed up the build process.<\/p>\n\n\n\n<p>Once the build process is complete, install Python 3.11 with the command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo make altinstall<\/code><\/pre>\n\n\n\n<p>We have used <code>altinstall<\/code>&nbsp;is used instead of&nbsp;<code>install<\/code>&nbsp; to keep the default Python binary path in&nbsp;<strong><em>\/usr\/bin\/python<\/em><\/strong>.<\/p>\n\n\n\n<p>Execution output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.......\nLooking in links: \/tmp\/tmprw_g09fu\nProcessing \/tmp\/tmprw_g09fu\/setuptools-65.5.0-py3-none-any.whl\nProcessing \/tmp\/tmprw_g09fu\/pip-22.3.1-py3-none-any.whl\nInstalling collected packages: setuptools, pip\nSuccessfully installed pip-22.3.1 setuptools-65.5.0\nWARNING: 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\/venv<\/code><\/pre>\n\n\n\n<p>Once complete, check the version:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-pink-color\"> python3.11 --version<\/mark>\nPython 3.11.7<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Install Python Extensions<\/h3>\n\n\n\n<p>Python modules are important since they add functionality to Python. These modules can be installed using the &nbsp;<strong>Python Package manager<\/strong>&nbsp;(PIP).<\/p>\n\n\n\n<p>Install PIP on Ubuntu:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>curl -sS https:\/\/bootstrap.pypa.io\/get-pip.py | python3.11 <\/code><\/pre>\n\n\n\n<p>Confirm it&#8217;s installed by checking the version:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-pink-color\">pip3.11 -V<\/mark>\npip 23.0.1 from \/usr\/local\/lib\/python3.11\/dist-packages\/pip (python 3.11)<\/code><\/pre>\n\n\n\n<p>Now use PIP to install any module. The command to use has the syntax:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-purple-color\">pip3.11<\/mark> install <em>module-name<\/em><\/code><\/pre>\n\n\n\n<p>For example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-purple-color\">pip3.11<\/mark> install <em>awscli<\/em><\/code><\/pre>\n\n\n\n<p>Sample output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>....\nCollecting rsa&lt;4.8,&gt;=3.1.2\n  Downloading rsa-4.7.2-py3-none-any.whl (34 kB)\nCollecting jmespath&lt;2.0.0,&gt;=0.7.1\n  Downloading jmespath-1.0.1-py3-none-any.whl (20 kB)\nCollecting python-dateutil&lt;3.0.0,&gt;=2.1\n  Downloading python_dateutil-2.8.2-py2.py3-none-any.whl (247 kB)\n     \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501 247.7\/247.7 kB 52.1 MB\/s eta 0:00:00\nRequirement already satisfied: urllib3&lt;1.27,&gt;=1.25.4 in \/usr\/lib\/python3\/dist-packages (from botocore==1.29.78-&gt;AWSCLI) (1.26.5)\nRequirement already satisfied: pyasn1&gt;=0.1.3 in \/usr\/lib\/python3\/dist-packages (from rsa&lt;4.8,&gt;=3.1.2-&gt;AWSCLI) (0.4.8)\nRequirement already satisfied: six&gt;=1.5 in \/usr\/lib\/python3\/dist-packages (from python-dateutil&lt;3.0.0,&gt;=2.1-&gt;botocore==1.29.78-&gt;AWSCLI) (1.16.0)\nInstalling collected packages: rsa, python-dateutil, jmespath, docutils, botocore, s3transfer, AWSCLI\nSuccessfully installed AWSCLI-1.27.78 botocore-1.29.78 docutils-0.16 jmespath-1.0.1 python-dateutil-2.8.2 rsa-4.7.2 s3transfer-0.6.0<\/code><\/pre>\n\n\n\n<p>You can list all the installed modules using the command;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-pink-color\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-purple-color\">pip3.11<\/mark> list<\/mark>\nPackage                Version\n---------------------- ---------------\nattrs                  21.2.0\nAutomat                20.2.0\nawscli                 1.27.78\nBabel                  2.8.0\nbcrypt                 3.2.0\nblinker                1.4\nbotocore               1.29.78\ncertifi                2020.6.20\nchardet                4.0.0\nclick                  8.0.3\ncloud-init             22.4.2\ncolorama               0.4.4\ncommand-not-found      0.3\nconfigobj              5.0.6\nconstantly             15.1.0\ncryptography           3.4.8\ndbus-python            1.2.18\ndistro                 1.7.0\ndistro-info            1.1build1\ndocutils               0.16\nhttplib2               0.20.2\nhyperlink              21.0.0\nidna                   3.3\nimportlib-metadata     4.6.4\nincremental            21.3.0\n......<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>We have successfully gone through how to install Python 3.11 on Ubuntu 22.04|20.04|18.04. You can now use the installed Python 3.11 to build web applications, create workflows, software development etc.<\/p>\n\n\n\n<p>See more:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/computingforgeeks.com\/install-java-on-rocky-almalinux-9\/\">Install Java 17, Java 11 on Rocky Linux 9 \/ AlmaLinux 9<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/computingforgeeks.com\/deploy-django-rocky-almalinux\/\">Deploy Python 3 Django Application on CentOS 7 with Apache and mod_wsgi<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/computingforgeeks.com\/5-best-computer-programming-books-for-beginners\/\">Best Books for Learning Python Programming<\/a><\/li>\n<\/ul>\n\n","protected":false},"excerpt":{"rendered":"<p>Programming plays a huge role in the tech world. Without it, you wouldn&#8217;t be able to view this article or use your phone, computer, smart TV etc. In this technology-driven world, learning programming can really give you a competitive edge. This can help innovate and create solutions for the global society. Programming can be defined &#8230; <a title=\"How To Install Python 3.11 on Ubuntu 22.04|20.04|18.04\" class=\"read-more\" href=\"https:\/\/computingforgeeks.com\/how-to-install-python-on-ubuntu-linux\/\" aria-label=\"Read more about How To Install Python 3.11 on Ubuntu 22.04|20.04|18.04\">Read more<\/a><\/p>\n","protected":false},"author":21,"featured_media":71902,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[690,299,50,68,81],"tags":[38192],"class_list":["post-131488","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-dev","category-how-to","category-linux-tutorials","category-programming","category-ubuntu","tag-python-3-11-on-ubuntu"],"_links":{"self":[{"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/posts\/131488","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/users\/21"}],"replies":[{"embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/comments?post=131488"}],"version-history":[{"count":2,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/posts\/131488\/revisions"}],"predecessor-version":[{"id":163153,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/posts\/131488\/revisions\/163153"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/media\/71902"}],"wp:attachment":[{"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/media?parent=131488"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/categories?post=131488"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/tags?post=131488"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}