{"id":9701,"date":"2021-07-16T13:20:31","date_gmt":"2021-07-16T10:20:31","guid":{"rendered":"https:\/\/kifarunix.com\/?p=9701"},"modified":"2024-03-18T19:38:10","modified_gmt":"2024-03-18T16:38:10","slug":"install-python-on-rocky-linux-8","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/install-python-on-rocky-linux-8\/","title":{"rendered":"Install Python on Rocky Linux 8"},"content":{"rendered":"\n<p>Follow through this guide to learn how to install Python on Rocky Linux 8. There exists different ways of installing Python on Linux systems. You can either install a specific version of Python from the source code or simply install the specific Python version from the specific Linux distro package repository.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Installing Python on Rocky Linux 8<\/h2>\n\n\n\n<p>As already mentioned, you can install Python by building from the source code or from the system package repositories.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Install Python 3.9 on Rocky Linux 8<\/h3>\n\n\n\n<p>As of this writing, the default Rocky Linux 8 AppStream repository provides Python 2, Python 3.6, 3.8, and 3.9.<\/p>\n\n\n\n<p>To install Python 3.9 on Rocky Linux 8, run the command below;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>dnf install python39<\/code><\/pre>\n\n\n\n<pre class=\"scroll-box\"><code>\nDependencies resolved.\n============================================================================================================================================================================\n Package                                        Architecture                Version                                                    Repository                      Size\n============================================================================================================================================================================\nInstalling:\n python39                                       x86_64                      3.9.2-1.module+el8.4.0+574+843c4898                        appstream                       31 k\nInstalling dependencies:\n python39-libs                                  x86_64                      3.9.2-1.module+el8.4.0+574+843c4898                        appstream                      8.1 M\n python39-pip-wheel                             noarch                      20.2.4-3.module+el8.4.0+574+843c4898                       appstream                      1.3 M\n python39-setuptools-wheel                      noarch                      50.3.2-3.module+el8.4.0+574+843c4898                       appstream                      496 k\nInstalling weak dependencies:\n python39-pip                                   noarch                      20.2.4-3.module+el8.4.0+574+843c4898                       appstream                      2.0 M\n python39-setuptools                            noarch                      50.3.2-3.module+el8.4.0+574+843c4898                       appstream                      870 k\nEnabling module streams:\n python39                                                                   3.9                                                                                            \n\nTransaction Summary\n============================================================================================================================================================================\nInstall  6 Packages\n\nTotal download size: 13 M\nInstalled size: 45 M\nIs this ok [y\/N]: y\n<\/code><\/pre>\n\n\n\n<p>Once installed, you can always counter check the installed version of Python, if you dont already have other versions installed;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>python3 -V<\/code><\/pre>\n\n\n\n<p>Sample output;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Python 3.9.2<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Install Python 3.8 on Rocky Linux 8<\/h3>\n\n\n\n<p>To install Python 3.8 simply execute the command below;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>dnf install python38<\/code><\/pre>\n\n\n\n<pre class=\"scroll-box\"><code>\nDependencies resolved.\n============================================================================================================================================================================\n Package                                        Architecture                Version                                                    Repository                      Size\n============================================================================================================================================================================\nInstalling:\n python38                                       x86_64                      3.8.6-3.module+el8.4.0+595+c96abaa2                        appstream                       78 k\nInstalling dependencies:\n python38-libs                                  x86_64                      3.8.6-3.module+el8.4.0+595+c96abaa2                        appstream                      8.3 M\n python38-pip-wheel                             noarch                      19.3.1-1.module+el8.4.0+570+c2eaf144                       appstream                      1.2 M\n python38-setuptools-wheel                      noarch                      41.6.0-4.module+el8.4.0+570+c2eaf144                       appstream                      303 k\nInstalling weak dependencies:\n python38-pip                                   noarch                      19.3.1-1.module+el8.4.0+570+c2eaf144                       appstream                      1.9 M\n python38-setuptools                            noarch                      41.6.0-4.module+el8.4.0+570+c2eaf144                       appstream                      666 k\nEnabling module streams:\n python38                                                                   3.8                                                                                            \n\nTransaction Summary\n============================================================================================================================================================================\nInstall  6 Packages\n\nTotal download size: 12 M\nInstalled size: 45 M\nIs this ok [y\/N]: y\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Install Python 3.6 on Rocky Linux 8<\/h3>\n\n\n\n<p>To install Python 3.6 simply execute the command below;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>dnf install python36<\/code><\/pre>\n\n\n\n<pre class=\"scroll-box\"><code>\nDependencies resolved.\n============================================================================================================================================================================\n Package                                   Architecture                  Version                                                     Repository                        Size\n============================================================================================================================================================================\nInstalling:\n python36                                  x86_64                        3.6.8-2.module+el8.4.0+597+ddf0ddea                         appstream                         18 k\nInstalling dependencies:\n python3-pip                               noarch                        9.0.3-19.el8.rocky                                          appstream                         19 k\n python3-setuptools                        noarch                        39.2.0-6.el8                                                baseos                           162 k\nEnabling module streams:\n python36                                                                3.6                                                                                               \n\nTransaction Summary\n============================================================================================================================================================================\nInstall  3 Packages\n\nTotal download size: 198 k\nInstalled size: 466 k\nIs this ok [y\/N]: y\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Install Python 2.7 on Rocky Linux 8<\/h3>\n\n\n\n<p>To install Python 2.7 simply execute the command below. Note that Python 2 is no longer supported.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>dnf install python2<\/code><\/pre>\n\n\n\n<pre class=\"scroll-box\"><code>\nDependencies resolved.\n============================================================================================================================================================================\n Package                                       Architecture                Version                                                     Repository                      Size\n============================================================================================================================================================================\nInstalling:\n python2                                       x86_64                      2.7.18-4.module+el8.4.0+403+9ae17a31                        appstream                      108 k\nInstalling dependencies:\n python2-libs                                  x86_64                      2.7.18-4.module+el8.4.0+403+9ae17a31                        appstream                      6.0 M\n python2-pip-wheel                             noarch                      9.0.3-18.module+el8.4.0+403+9ae17a31                        appstream                      1.0 M\n python2-setuptools-wheel                      noarch                      39.0.1-13.module+el8.4.0+403+9ae17a31                       appstream                      286 k\nInstalling weak dependencies:\n python2-pip                                   noarch                      9.0.3-18.module+el8.4.0+403+9ae17a31                        appstream                      1.7 M\n python2-setuptools                            noarch                      39.0.1-13.module+el8.4.0+403+9ae17a31                       appstream                      641 k\nEnabling module streams:\n python27                                                                  2.7                                                                                             \n\nTransaction Summary\n============================================================================================================================================================================\nInstall  6 Packages\n\nTotal download size: 9.7 M\nInstalled size: 37 M\nIs this ok [y\/N]: y\n<\/code><\/pre>\n\n\n\n<p>Checking Python 2.x version;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>python2 -V<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>Python 2.7.18<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">List All Available Python Versions<\/h3>\n\n\n\n<p>To list all available versions of Python, run the command below;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>ls -alh1 \/usr\/bin\/python*<\/code><\/pre>\n\n\n\n<pre class=\"scroll-box\"><code>\nlrwxrwxrwx. 1 root root    9 May 30 22:43 \/usr\/bin\/python2 -> python2.7\n-rwxr-xr-x. 1 root root 7.9K May 30 22:43 \/usr\/bin\/python2.7\nlrwxrwxrwx. 1 root root   25 Jul 16 11:53 \/usr\/bin\/python3 -> \/etc\/alternatives\/python3\nlrwxrwxrwx. 1 root root   31 Jul  2 19:01 \/usr\/bin\/python3.6 -> \/usr\/libexec\/platform-python3.6\nlrwxrwxrwx. 1 root root   32 Jul  2 19:01 \/usr\/bin\/python3.6m -> \/usr\/libexec\/platform-python3.6m\n-rwxr-xr-x. 1 root root 7.6K Jun 30 00:16 \/usr\/bin\/python3.8\n-rwxr-xr-x. 1 root root 7.6K Jun 11 20:24 \/usr\/bin\/python3.9\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Setting Default Python Version<\/h3>\n\n\n\n<p>If you have multiple versions of Python installed, you can use <strong>alternatives<\/strong> command to set your default version of Python.<\/p>\n\n\n\n<p>For example, you can run the command below to set your default version of Python.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>update-alternatives --config python<\/code><\/pre>\n\n\n\n<p>Sample output;<\/p>\n\n\n\n<pre class=\"scroll-box\"><code>\nThere are 5 programs which provide 'python'.\n\n  Selection    Command\n-----------------------------------------------\n*+ 1           \/usr\/libexec\/no-python\n   2           \/usr\/bin\/python3\n   3           \/usr\/bin\/python3.9\n   4           \/usr\/bin\/python3.8\n   5           \/usr\/bin\/python2\n\nEnter to keep the current selection[+], or type selection number: 2\n<\/code><\/pre>\n\n\n\n<p>Select  enter specific number that defines the version of Python you want to set as the default version and press ENTER key. The + symbol shows the current default version.<\/p>\n\n\n\n<p>In the above, option 2 was selected, which sets Python 3.6.8 as the default version;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>python -V<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>Python 3.6.8<\/code><\/pre>\n\n\n\n<p>You can also use the command below to set default Python version.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>alternatives --install &lt;link&gt; &lt;name&gt; &lt;path&gt; &lt;priority&gt;<\/code><\/pre>\n\n\n\n<p>For example;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>update-alternatives --install \/usr\/bin\/python python \/usr\/bin\/python3.9 1<\/code><\/pre>\n\n\n\n<p>You can list the alternatives;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>update-alternatives --list<\/code><\/pre>\n\n\n\n<pre class=\"scroll-box\"><code>\nlibnssckbi.so.x86_64\tauto  \t\/usr\/lib64\/pkcs11\/p11-kit-trust.so\npython              \tmanual\t\/usr\/bin\/python3\nifup                \tauto  \t\/usr\/libexec\/nm-ifup\ncifs-idmap-plugin   \tauto  \t\/usr\/lib64\/cifs-utils\/cifs_idmap_sss.so\nld                  \tauto  \t\/usr\/bin\/ld.bfd\nnmap                \tauto  \t\/usr\/bin\/ncat\npython3             \tauto  \t\/usr\/bin\/python3.6\n<\/code><\/pre>\n\n\n\n<p>To remove alternatives;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>alternatives --remove-all python<\/code><\/pre>\n\n\n\n<p>And that is how easy it is to install Python.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Other Tutorials<\/h3>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/install-elk-stack-on-rocky-linux-8\/\" target=\"_blank\" rel=\"noreferrer noopener\">Install ELK Stack on Rocky Linux 8<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/install-mongodb-on-rocky-linux-8\/\" target=\"_blank\" rel=\"noreferrer noopener\">Install MongoDB on Rocky Linux 8<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/install-latest-nodejs-on-rocky-linux-8\/\" target=\"_blank\" rel=\"noreferrer noopener\">Install Latest Nodejs on Rocky Linux 8<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Follow through this guide to learn how to install Python on Rocky Linux 8. There exists different ways of installing Python on Linux systems. You<\/p>\n","protected":false},"author":3,"featured_media":9706,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_lock_modified_date":false,"footnotes":""},"categories":[121],"tags":[3852,3851,3855,3854,3007,3853],"class_list":["post-9701","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-howtos","tag-install-python-on-rocky-linux-8","tag-python","tag-python-3-1","tag-python-3-9","tag-python3-8","tag-rocky-linux-python","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-50","resize-featured-image"],"_links":{"self":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/9701"}],"collection":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/comments?post=9701"}],"version-history":[{"count":4,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/9701\/revisions"}],"predecessor-version":[{"id":21729,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/9701\/revisions\/21729"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media\/9706"}],"wp:attachment":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media?parent=9701"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/categories?post=9701"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/tags?post=9701"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}