Close Menu
  • How to
  • Apps
  • Games
  • MOD APK
  • Root
  • About Us
  • Privacy Policy
  • Disclaimer
  • Contact Us
  • Write For Us
AndroidFit
  • How to
  • Apps
  • Games
  • MOD APK
  • Root
AndroidFit

How to Install Python on Termux

By AndroidFit Android Apps
Share Facebook WhatsApp Twitter Pinterest Telegram Copy Link
How To Install Python on Android using Termux
How To Install Python on Android using Termux

Ever wondered if you can run Python scripts on your smartphone? Writing Python code on touchscreen devices with small displays can be tough, but it’s convenient when you need to quickly test a Python script but don’t want to get out of bed and fire up your PC.

Installing Python on a computer is easy. But what if you want to code in Python on Android? You can install Python using Termux.

Installing Python on an Android smartphone using Termux is easy. We’ll walk you through the entire process, from downloading Termux to running your first Python program on an Android device.

Install Termux on Android

Termux is a terminal emulator for Android. To install it on your smartphone, head over to F-Droid and download the latest APK available.

Download: Termux (F-Droid)

Once downloaded, locate and tap on the APK file to begin the installation. When asked for confirmation, tap Install.

Although Termux is available to download from the Google Play Store, as of this writing, the pre-configured repositories throw a 404 error when you try to install a package or update existing ones.

How to Install Python on Termux

Before installing Python, the first step is to update existing packages. The default package manager on Termux is pkg, which is quite similar to Debian or Ubuntu’s APT in terms of syntax and arguments.

To update packages on Termux, run:

pkg upgrade

When prompted for Y/N confirmations, tap Enter to go with the defaults. You’ll have to do this a couple of times during the process.

How to Install Python on Termux
How to Install Python on Termux

Then, enter the following command to install Python:

pkg install python

Enter Y when prompted for confirmation.

If you wish to install Python 2 instead, run:

pkg install python2

PIP and PIP2 will be installed along with the python and python2 packages, respectively, so rest assured you can install libraries and modules that you frequently work with.

Running the Python Interactive Shell

With Python installed, it’s time to test whether the installation was successful. In the terminal, enter “python” to launch the interactive shell (“python2” if you installed the old version).

If everything went well, you’ll see the version of Python listed at the top along with some helpful information. As with any other language, test out the interpreter by typing the following statement to print “Hello, World“:

print("Hello, World")

The output will display the string “Hello, World” and then switch back to input mode. When you’ve played with the interactive shell enough and want to go back to the terminal, type “exit()” and hit Enter.

Writing Your First Python Script on Termux

To take it a step further, why not create a Python script and execute it using Termux? To begin, first open nano, a terminal-based text editor for Linux. If you want to use another text editor, feel free to install it with the pkg install command.

Enter the following to create a new Python script file in the current directory:

nano script.py

Add the following lines of code to the file:

print("Hello, World")
name = input("What's your name? ")
print("Enjoy Python programming on Termux", name)

To save changes to the file, tap the Ctrl button and hit O. Then, press Enter to save the file. To exit nano, tap Ctrl and X.

Writing Your First Python Script on Termux
Writing Your First Python Script on Termux

Run the script by issuing the following command:

python script.py

Python 2 users would need to substitute “python” in the above command with “python2”. The program will display “Hello, World” and ask for your name. Once you specify that and tap Enter, it’ll output the final string with your name appended at the end.

Faq

Can Termux run python?

A few python packages are available from termux’s package manager (for python3 only), and should be installed from there to avoid compilation errors. This is the case for: numpy, pkg install python-numpy. electrum, pkg install electrum.

How do I run a .PY file in Termux Android?

Move to the newly created folder with cd ./termux/tasker and use vim or nano to create your script. You’ll probably have to do pkg install python too. Then move to Tasker, create a task and name it whatever you want. Inside the task, add a Plugin:Termux command and set the config to the script you’re running.

Can I install Django with Termux?

Yes, you can do it. After creating Creating a virtual environment, you can instal the Django framework

Also check this

  1. Mini Militia Cheats, Chat Codes, Hacks and Tips (Doodle Army 2 Mini militia tips)
  2. Little Big City 2 Mod APK for Free Unlimited Diamonds, Money – 100% working
  3. Is Signal Tracking Performed When the Phone is Off?
  4. What is OsuLogin on Android? Know everything about OsuLogin
  5. How to Block Any Website on Android Devices
Share. Facebook Twitter Pinterest Email Telegram WhatsApp Copy Link
Previous ArticleApps That Are Changing The Automotive Industry
Next Article How to Bypass Google Account Verification After Reset [2025 Update]
AndroidFit
  • Website
  • Facebook

Hi, Here's AndroidFit admin!! I always try to give my best to this website..

Related Posts
Android Apps

Top 10 Best Fast and Secure Android VPN Apps in 2025

May 20, 2025
Android Apps

12 Best Clipboard History Manager Apps for Android (2025 Edition)

May 13, 2025
Android Apps

How to Build Your Ultimate Fitness Plan with Android Apps

April 1, 2025
Add A Comment
Leave A Reply Cancel Reply

Latest Posts
Top 10 Best Fast and Secure Android VPN Apps in 2025
May 20, 2025
10 Best Free Workout Apps for Android in 2025 (Fitness Workout Apps)
May 20, 2025
How to Recover Deleted Photos and Videos on Android in 2025
May 20, 2025
Top 10 Free and Legal eBook Downloader Sites in 2025
May 20, 2025
How to Sign a PDF File on Android: A Step-by-Step Guide
May 19, 2025
12 Best Clipboard History Manager Apps for Android (2025 Edition)
May 13, 2025
How to Install Google Play Store and Google Apps on Windows Subsystem for Android (WSA)
April 18, 2025
Fix “Something Went Wrong, Try Again” Error on Google Play Store (Android)
April 10, 2025
The 12 Best Offline Games on Android That Don’t Need Internet (2025 Edition)
April 2, 2025
How to Build Your Ultimate Fitness Plan with Android Apps
April 1, 2025
© 2025 AndroidFit
  • About Us
  • Privacy Policy
  • Disclaimer
  • Contact Us
  • Write For Us

Type above and press Enter to search. Press Esc to cancel.