How To Run Python Interactive Command Line Mode (CLI)


PS C:\WINDOWS\system32> python
Python 3.8.0 (tags/v3.8.0:fa919fd, Oct 14 2019, 19:37:50) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.

Use exit() or Ctrl-Z plus Return to exit
>>> quit
Use quit() or Ctrl-Z plus Return to exit
>>> ^Z


# This would happen if python hasn't been installed
kim@kim-linux:~$ python
Command 'python' not found, did you mean:
  command 'python3' from deb python3
  command 'python' from deb python-is-python3
# Installing python
kim@kim-linux:~$ sudo apt install python
[sudo] password for kim:          
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Note, selecting 'python-is-python2' instead of 'python'
The following NEW packages will be installed:
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 2,496 B of archives.
After this operation, 10.2 kB of additional disk space will be used.
Get:1 focal/universe amd64 python-is-python2 all 2.7.17-4 [2,496 B]
Fetched 2,496 B in 0s (8,830 B/s)             
Selecting previously unselected package python-is-python2.
(Reading database ... 386392 files and directories currently installed.)
Preparing to unpack .../python-is-python2_2.7.17-4_all.deb ...
Unpacking python-is-python2 (2.7.17-4) ...
Setting up python-is-python2 (2.7.17-4) ...

# Enter python interactive mode
kim@kim-linux:~$ python
Python 2.7.18 (default, Mar  8 2021, 13:02:45) 
[GCC 9.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> Ctrl+ D # exit python environment

Leave a Reply

Your email address will not be published. Required fields are marked *