How to Install Python on Android Using Termux Application

Everyone is busy these days, but a lot of time is wasted when you commute to your school/college/work. Likewise, if I write down every single scenario where our precious time is getting wasted, that alone would take an entire day. Wouldn’t it be amazing if you can efficiently put all this wasted time to use? Like by learning Python or by finishing off that Python assignment on the go? Well, taking a laptop everywhere isn’t really feasible? How about taking your Android mobile instead then?


ADVERTISEMENT

In this article, we explain in detail how you can instantly install the Termux application, which is an Android emulator, using which you can set up the Linux environment on your Android device. Using Linux, you can readily install the Python package and start coding in Python on the go, just as simple as that!

Solution

Step 1: Firstly, let’s install the Termux application on your Android device. For that, launch the Google Play Store application by clicking on its icon.

 

1 Play Store Min

 

Step 2: Using the search bar, search for the Termux application and hit the Install button associated with the Termux application from the search results.

 

2 Install Termux Min

 

Step 3: Once Termux is installed, hit the Open button to launch it.


ADVERTISEMENT

 

3 Open Min

 

Step 4: When the Termux application launches open, on the Termux terminal, type in the following command and hit the Enter key to install python3 onto your device.

pkg install python3

Note: If you would like to install Python 2, the command would be pkg install python2.

Once you are done, hit the Enter key on the keyboard.

 

4 Pkg Install Min

 

Step 5: When you get the following confirmation request, hit the key y on your keyboard and then the Enter key as shown below.

Note: During the time of Python package installation, you might get an error that says that the Termux repository is under maintenance or down. This would prevent the installation process from proceeding. In that case, to resolve the issue, you can refer to our article here.

 

5 Yes Min

 

Step 6: Wait till the installation process runs to completion. At the end of it, you should see a $ character indicating that the process has run to completion, freeing the terminal.

 

6 Installed Min

 

Step 7: Let’s now check whether Python is successfully installed on your device or not. For that, type in python on the terminal and hit the Enter key.

 

7 Python Min

 

Step 8: You should be able to see the version of the Python package installed on your device as shown below, indicating that the installation process has been successful.

 

8 Version Min

 

Step 9: That’s it. You can now start coding in Python right from your Android device. Once you are done typing a Python line, hit the Enter key to see the output.

 

9 Code Min


ADVERTISEMENT

 

Step 10: The following screenshot gives an example of how a Python output would look in Termux.

 

10 Output Printed Min

 

Step 11: If you would like to terminate Python, just like in Linux, press the CTRL key first and then hit the key Z. This would terminate the running process, which is Python in our case. Enjoy!

 

11 Terminate Min

 

Hope you found the article useful.

ADVERTISEMENT