How to Install Python in Linux CentOS 8 virtual server running in VirtualBox Application

Posted on

This article will show how to install python in Linux CentOS 8. Precisely, it is the installation of python in a virtual server running with Linux CentOS 8 as its operating system. The virtual server is running in VirtualBox application. In order to install python, the following are the steps for the python installation :

1. Access the Windows Command Prompt. The following is the display for the interface of the Windows Command Prompt :

Microsoft Windows [Version 10.0.18362.1082]
(c) 2019 Microsoft Corporation. All rights reserved.
C:\Users\Personal>

2. Use an SSH remote connection to access the virtual server. Read the article with the title ‘How to Add SSH Port Forwarding Rule to remote Guest Machine running in VirtualBox Manager from Host Machine’ in this link to access the server using SSH remote connection. There is also another method for accesing the virtual server. It is directly access the virtual server by running it in the VirtualBox application. The following access is using port 9922 in the host machine to access the SSH port in the virtual server.

C:\Users\Personal>ssh -p 9922 admin@localhost
admin@localhost's password:
Activate the web console with: systemctl enable --now cockpit.socket
Last login: Thu Jan  7 02:55:14 2021 from 10.0.2.2
[admin@10 ~]$

3. After successfully access the virtual server as in the above step using SSH remote connection, try to type ‘python’. It is useful to check whether ‘python’ is actually exist or not as follows :

[admin@10 ~]$ python
-bash: python: command not found
[admin@10 ~]$

4. Apparently, the python tool or utility does not exist in the virtual server. So, execute the following command to install python tool or utility as follows :

[admin@10 ~]$ sudo dnf install python3
[sudo] password for admin:
Last metadata expiration check: 3:12:15 ago on Thu 07 Jan 2021 06:02:51 AM EST.
Dependencies resolved.
============================================================================================================================================================================ Package                                         Architecture                Version                                                   Repository                      Size
============================================================================================================================================================================Installing:
 python36                                        x86_64                      3.6.8-2.module_el8.3.0+562+e162826a                       AppStream                       19 k
Upgrading:
 platform-python-pip                             noarch                      9.0.3-18.el8                                              BaseOS                         1.7 M
 platform-python-setuptools                      noarch                      39.2.0-6.el8                                              BaseOS                         632 k
Installing dependencies:
 python3-pip                                     noarch                      9.0.3-18.el8                                              AppStream                       20 k
 python3-setuptools                              noarch                      39.2.0-6.el8                                              BaseOS                         163 k
Enabling module streams:
 python36                                                                    3.6
Transaction Summary
============================================================================================================================================================================Install  3 Packages
Upgrade  2 Packages
Total download size: 2.5 M
Is this ok [y/N]: y
Downloading Packages:
(1/5): python3-setuptools-39.2.0-6.el8.noarch.rpm                                                                                           907 kB/s | 163 kB     00:00
(2/5): python3-pip-9.0.3-18.el8.noarch.rpm                                                                                                   17 kB/s |  20 kB     00:01
(3/5): python36-3.6.8-2.module_el8.3.0+562+e162826a.x86_64.rpm                                                                               17 kB/s |  19 kB     00:01
(4/5): platform-python-pip-9.0.3-18.el8.noarch.rpm                                                                                          967 kB/s | 1.7 MB     00:01
(5/5): platform-python-setuptools-39.2.0-6.el8.noarch.rpm                                                                                   632 kB/s | 632 kB     00:01
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------Total                                                                                                                                       773 kB/s | 2.5 MB     00:03
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                                                                                                    1/1
  Upgrading        : platform-python-setuptools-39.2.0-6.el8.noarch                                                                                                                                                                     1/7
  Installing       : python3-setuptools-39.2.0-6.el8.noarch                                                                                                                                                                             2/7
  Upgrading        : platform-python-pip-9.0.3-18.el8.noarch                                                                                                                                                                            3/7
  Installing       : python36-3.6.8-2.module_el8.3.0+562+e162826a.x86_64                                                                                                                                                                4/7
  Running scriptlet: python36-3.6.8-2.module_el8.3.0+562+e162826a.x86_64                                                                                                                                                                4/7
  Installing       : python3-pip-9.0.3-18.el8.noarch                                                                                                                                                                                    5/7
  Cleanup          : platform-python-pip-9.0.3-16.el8.noarch                                                                                                                                                                            6/7
  Cleanup          : platform-python-setuptools-39.2.0-5.el8.noarch                                                                                                                                                                     7/7
  Running scriptlet: platform-python-setuptools-39.2.0-5.el8.noarch                                                                                                                                                                     7/7
  Verifying        : python3-pip-9.0.3-18.el8.noarch                                                                                                                                                                                    1/7
  Verifying        : python36-3.6.8-2.module_el8.3.0+562+e162826a.x86_64                                                                                                                                                                2/7
  Verifying        : python3-setuptools-39.2.0-6.el8.noarch                                                                                                                                                                             3/7
  Verifying        : platform-python-pip-9.0.3-18.el8.noarch                                                                                                                                                                            4/7
  Verifying        : platform-python-pip-9.0.3-16.el8.noarch                                                                                                                                                                            5/7
  Verifying        : platform-python-setuptools-39.2.0-6.el8.noarch                                                                                                                                                                     6/7
  Verifying        : platform-python-setuptools-39.2.0-5.el8.noarch                                                                                                                                                                     7/7
Upgraded:
  platform-python-pip-9.0.3-18.el8.noarch                                                                           platform-python-setuptools-39.2.0-6.el8.noarch
Installed:
  python3-pip-9.0.3-18.el8.noarch                                      python3-setuptools-39.2.0-6.el8.noarch                                      python36-3.6.8-2.module_el8.3.0+562+e162826a.x86_64
Complete!
[admin@10 ~]$

As in the above output, python installation is finish. The following access is using port 9922 in the host machine to access the SSH port in the virtual server. In order to make sure the python tool exist, login to the virtual server and just type ‘python’ again in the command line interface as follows :

Microsoft Windows [Version 10.0.18362.1082]
(c) 2019 Microsoft Corporation. All rights reserved.
C:\Users\Personal>ssh -p 9922 admin@localhost
admin@localhost's password:
Activate the web console with: systemctl enable --now cockpit.socket
Last login: Wed Jan 27 23:27:42 2021
Activate the web console with: systemctl enable --now cockpit.socket
Last login: Wed Jan 27 23:27:42 2021
[admin@10 ~]$ python
-bash: python: command not found
[admin@10 ~]$ python3
Python 3.6.8 (default, Apr 16 2020, 01:36:27)
[GCC 8.3.1 20191121 (Red Hat 8.3.1-5)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> quit
Use quit() or Ctrl-D (i.e. EOF) to exit
>>> quit()
[admin@10 ~]$

Leave a Reply