Join WhatsApp

Join Now

Join Telegram

Join Now

How To Install Python In Termux | Latest 2024

By Saboor Shawkat

Updated on:

Python In Termux
5/5 - (2 votes)

In This Post I Am Going To Show You How To Install Python In Termux. I Will Guide you Through The Basic Step By Step Process Of How To Install Python In Termux And Also We Will Discuss About The Definitions And Uses Of The Python In Termux. So Let’s Start From The Basic That Is The Definition Of Python In Termux.

What Is Python?

Python Is Programing Language That Can Be Used To Program Apps, Websites And Other Type Of Resources. This Language Is Much Easier As Compared To Other Languages And Has Much Extendability Than Other Language. You Can Generate Your Own AI With This Language. This Language Was Created By Guido Van Rossum And Is One Of The Fastest Languages Known So Far. Different Versions Of Python Are Available And Till Date Python 3 Is The Latest One.

How To Install Python In Termux?

Python Is An Easy Language And Is Much Friendly So Sometimes We Want To Install It In Our Android Device. This Can Be Done With The Help Of Termux App. We Can Easily Install Python In Termux And Use It’s Resources For Our Projects. Python Can Be Easily Installed In Termux As Termux Packages Already Contains The Python Package In Their Package List. Follow The Below Steps One By One To Install Python In Termux:

Step 1: Open The Termux App, If You Don’t Have Termux App. Go To The Play Store And Download It.

Step 2: In Order To Install Packages We Need To Update And Upgrade Termux, For That Type pkg update && pkg upgrade -y In Termux.

ShellScript
pkg update && pkg upgrade -y

Step 3: Now Let’s Give The Storage Permissions To The App By Typing Command termux-setup-storage And Then Allowing The Storage Permissions.

ShellScript
termux-setup-storage

Step 4: Now Install Python Using Command pkg install python -y In Termux.

ShellScript
pkg install python -y
Install Python In Termux

Step 5: Install Other Versions Of Python In Termux Using Command pkg install python2 -y In Termux.

ShellScript
pkg install python2 -y
Install Python 2 In Termux

Step 6: The Python Will Start Installing In Termux And Will Be Completed Shortly. Make Sure The Python Need Almost 500 MB Of Phone Storage.

Step 7: After The Python Has Been Installed Successfully You Can Test It Using python –version Command.

ShellScript
python --version
Check Python Version In Termux

This Command Displays The Version Of The Python You Are Running Currently On Your Termux Machine.

How To Install Python In Termux Using Single Command?

Python Can Be Install Through A Single Command With It’s All Current Version. This Command Is Not A Different Command, It’s Just A Sum Up Commands Of All Command Using “&&”. Type pkg update && pkg upgrade -y && pkg install python -y && pkg install python2 -y Command In Termux To Install Python With A Single Command.

ShellScript
pkg update && pkg upgrade -y && pkg install python -y && pkg install python2 -y

This Command And All Other Commands For Installation Will Require A Network Connection. I Hope You Completely Learned How To Install Python In Termux. Now We Will See How We Can Use Python In Termux.

How To Use Python In Termux?

After Installing Python In Termux We Can Use Python Program To Open, Create Python Files Or Programs. There Are Many Functionalities That Can Be Used In Termux. Let’s See Some Of Them:

  • To Start Python Programming: To Start Programming In Python Using Termux You Need To Type python Command, Then “>>>” Will Start Before A Shell And You Can Start Writing Your Python Program.
ShellScript
python
Starting Python In Termux
  • To Open Any Python File: We Can Use Python To Open And Read Python Files. To Open Any Python File Type python {filename.py} To Read Or Open That File. Make Sure To Change {filename.py} With Your Own Python File Name.
ShellScript
python {filename.py}

Besides These Functions You Can Save These Files And Run In Python. I Hope You Have Understood That. Now Let’s See Some Short Codes Of Python:

Some Projects Of Python In Termux:

Project 1: To List Geek Times By Saboor We Can Write A Python Code Like:

Python
# List of Geek Times articles by Saboor
geek_times = [
    "Learn About Linux Basics",
    "Learn About Termux Basica",
    "Top 10 Tools Of Termux In 2023",
    "Introduction to Data Science",
    "Building RESTful APIs with Flask"
]

# Function to display articles
def display_geek_times(articles):
    print("Geek Times by Saboor:")
    for idx, article in enumerate(articles, start=1):
        print(f"{idx}. {article}")

# Call the function to display the articles
display_geek_times(geek_times)

Project 2: To Calculate Your Age Using Birthday In Python We Can Write A Code Like This:

Python
from datetime import datetime

def calculate_age(birthdate):
    today = datetime.now()
    age = today.year - birthdate.year - ((today.month, today.day) < (birthdate.month, birthdate.day))
    return age

# Get user input
birthdate_str = input("Enter your birthdate (YYYY-MM-DD): ")
birthdate = datetime.strptime(birthdate_str, "%Y-%m-%d")

# Calculate and display age
age = calculate_age(birthdate)
print(f"You are {age} years old.")

These Were Some Cool Projects Of Python That Can Be Programmed On Termux Also.

How To Remove Python From Termux?

Installing Python Is An Easy Task And After Installing It We Can Remove It By A Single Command Also. Type pkg uninstall python To Remove Python From Termux. This Will Remove Python And It’s Files From Termux.

ShellScript
pkg uninstall python

If You Somehow Did This Command Accidentally You Can Install It Again With The Above Commands.

Conclusion:

Python Is A Cool Language To Work On And To Find New Opportunities. In 2024 Python Was One Of The Most Learning Languages As It Is Easy And Has Much Big Environment To Work On. Python Can Be Used In AI And Other Programming. I Hope You Have Completely Understood How To Install And Use Python In Termux. If You Got Any Query Related To This Post You Can Just Comment Or Contact Us, I Will Try My Best To Help You. Thanks For Reading..❤️

Frequently Asked Questions:

  1. What Is Python Used For?

    Python Can Used To Build Different Programmes, Websites And AI

  2. How To Install Python In Termux?

    Type pkg install python -y To Install Python In Termux.

  3. Is Python Easy To Learn?

    Yes, Python Is Easy To Learn Of Compared To JavaScript And Other Languages