How to Install and Run Python in Termux

What is Termux and installing Python in Termux?

Installing python in termux

You all know that Python is a popular programming language used in various fields like Web development, Game development, the Education sector, Artificial Intelligence, Machine learning, and many more. You can easily execute your Python code on your computer system or laptop but what do you do, if you want to execute that Python code in Android?

So today you will learn how to install and execute Python in Android using Termux.

Firstly, you will learn to install Termux in Android and then how you can execute Python code using Termux (Step by Step).

What is Termux?

Termux is a terminal application that gives you access to establish a Linux-compatible platform on your Android device and allows you to access all Linux software packages through a text-based terminal.

How to install Termux in Android?

Now, you will learn how to install and use Termux on your Android device (Step by Step).

Step 1:

Firstly, you have to visit this link.

F-DROID

Step 2:

Now you have an interface of F-Droid, Scroll down and click on Download APK (The first version is the default/suggested version of Termux according to your device).

Downloading Termux APK

Step 3:

After the completion of the download, press on the downloaded file to install Termux, and after installing, click on open to start Termux.

Installation of Termux

Step 4:

Now you will have the Termux Welcome Screen.

Termux Welcome Screen

Step 5:

Here you will have to give Storage Permission to it using Command.

termux-setup-storage

Termux Storage command

Step 6:

You will get a popup asking for permission to access the storage, Click allow.

Installing Python in Termux:

After installing Termux on your device, you have to follow the steps given below with proper images for better understanding.

Step 1:

Firstly, you have to type a commandapt update.

apt update

Step 2:

After completion of this command, type another command apt upgrade and between the execution of this command it will ask you for Yes[Y] or No[n], then type “Y”.

apt upgrade

Step 3:

Now type the command pkg install python and it also asks for Yes[Y] or No[n], so type “Y”.

Here you can also use these two commands pkg install python2 and pkg install python3 to install another version of Python.

pkg install python

Step 4:

Then type pkg install nano.

pkg install nano

Step 5:

To check the version of Python, you have to type the python –version command. If it doesn’t give any error then you have successfully installed Python in Termux.

python version

Steps to run Python in Termux:

Step 1:

Firstly, you have to create a file with a (.py) extension with the help of nano. So type

nano new.py (Here new is the name of the file).

Creating new file

Step 2:

After creating the file, you have a new interface and then type print(“Hello Guys”).

python file interface using nano

Step 3:

Now save the file by clicking on CTRL + X or the Volume down button + X.

Saving python file in termux

Step 4:

In the last step you have to type python new.py and the result “Hello Guys” will be printed.

Executing python file

I hope you successfully installed Python in Termux and executed your code.

Thanks for Visiting

Arvind Yadav

Welcome to my blogging realm ! I am ARVIND, a dedicated BCA student diving into the world of technology. Now you have the chance to join me on this exciting journey. I will explore the latest trends ,share insightful experiences and the endless possibilities that the digital world offers. Let's learn ,create and innovate together!

Post a Comment

Previous Post Next Post