Turns out, Python in Termux is what happens when you stop waiting for the perfect setup.
I was on a cramped bus in the middle of Manila traffic, laptop buried deep in my bag, when I got a message: “Can you send the script now?”
No Wi-Fi. No time. No space. Just an Android phone, a charger, and the sinking feeling that I couldn’t do real dev work on the go.
That changed the day I discovered Python in Termux. It wasn’t just about installing a language—it was about reclaiming computing power using the tools I already had. Free, open source, and right in my pocket.
If you’re a tinkerer, a student, or just someone tired of waiting for the “right gear,” this guide is for you. I’ll walk you through how to install Python in Termux in under 5 minutes—and show you how powerful your phone really is.
Let’s get started.
Download my FREE Python Infographic Now!
Why Install Python on Android?
Not everyone has access to a laptop or desktop computer, but nearly everyone has a smartphone. In many countries, students rely entirely on mobile devices for learning, making traditional programming education inaccessible. Python in Termux bridges this gap, allowing aspiring coders to write and run Python scripts directly on their phones.
When I first started creating coding tutorials on YouTube, I assumed my audience had access to full computers. But as messages poured in from students across the world, I realized how many were trying to learn Python using nothing but a mobile phone. Some had no other option. One student in Nigeria even confessed that he had stolen a phone just to keep up with his assignments. That revelation shook me.
That’s when I discovered Python in Termux—a lightweight but powerful way to run Python on Android. It enables students, hobbyists, and professionals to code anywhere, without needing a traditional computer. With Python in Termux, they can install libraries, manage virtual environments, and even build real-world projects—all from their smartphones.
For many students worldwide, Python in Termux isn’t just a convenience; it’s their only gateway to programming. It levels the playing field, allowing anyone with a smartphone to start coding today.
Before You Begin: A Quick Note on Termux and Linux
If you’re new to Termux or the Linux command line, don’t worry—you’re not alone. Termux is a powerful terminal emulator that brings a full Linux-like environment to Android, but it can feel unfamiliar if you’ve never used a command-line interface before.
Before proceeding, I highly recommend checking out How to Install Termux on Android: Run Linux Like a Pro (No PC Needed!) to get a solid foundation. That guide covers everything from installation to essential commands, ensuring you’re comfortable navigating Termux before diving into Python setup.
Now, let’s move on to installing Python in Termux the right way!
· · ─ ·𖥸· ─ · ·
Installing Python in Termux: What You Need to Know First
Before diving into the install process, it’s worth understanding what you’re actually setting up. Python in Termux isn’t just another mobile workaround—it’s a full-fledged development environment running on your Android device. Termux provides a terminal emulator with access to a lightweight Linux base, and once Python is installed, you can write scripts, run CLI tools, scrape web data, automate tasks, and even prototype full applications—all from your phone. It’s a compact but powerful combo, and with the right setup, it’s surprisingly smooth.
Step 1: Update Termux Packages
Before installing Python, it’s essential to update the Termux package list to ensure you have the latest versions of all available packages. Open Termux and run the following command:
pkg update && pkg upgrade
Step 2: Install Python in Termux
Now that your Termux environment is up-to-date, you can install Python. Execute the following command to install Python in Termux:
pkg install python
This command will install Python and its package manager, pip
, which you can use to install additional Python packages.
Step 3: Verify the Python Installation
After the installation is complete, verify that Python is installed correctly by checking its version. Run:
python --version
You should see the installed Python version displayed on your screen, confirming that Python is successfully installed in Termux.
Step 4: Install Python Packages Using pip
With Python installed, you can now use pip
to install additional packages. For example, to install the popular requests
library, run:
pip install requests
You can install any other Python packages you need using pip
.
Step 5: Setting Up a Virtual Environment
Creating a virtual environment is a best practice for managing dependencies for different projects. Here’s how to set up a virtual environment in Termux:
pip install requests
Install virtualenv
: First, install the virtualenv
package using pip
:
pip install virtualenv
Create a Virtual Environment:Create a new virtual environment by running:
virtualenv myenv
Replace myenv
with the name you want for your virtual environment.
Activate the Virtual Environment:To use the virtual environment, activate it with:
source myenv/bin/activate
Your prompt will change to indicate that the virtual environment is active. You can now install packages specific to this environment without affecting your global Python setup.
Deactivate the Virtual Environment:When you’re done working in the virtual environment, deactivate it with:
deactivate
Your prompt will return to its normal state.
Step 6: Create and Run a Python Script
To ensure everything is working correctly, let’s create a simple Python script and run it. Use a text editor to create a new file named hello.py
:
nano hello.py
Add the following code to the file:
print("Hello, Termux!")
Save the file and exit the editor. Run the script with:
python hello.py
You should see “Hello, Termux!” printed on the screen, indicating that your Python setup and virtual environment are working correctly.
Common Mistakes to Avoid When Installing Python in Termux
Installing Python in Termux is straightforward, but many beginners encounter avoidable issues. Here are the most common mistakes and how to prevent them:
1. Skipping Termux Updates
Before installing Python, always update Termux’s package list. Skipping this step can lead to broken dependencies or outdated versions. Run:
pkg update && pkg upgrade -y
This ensures you are working with the latest software versions.
2. Installing Python Without Required Packages
While pkg install python
is the main command, some projects require additional dependencies like pip
or clang
. To avoid issues later, install everything upfront:
pkg install python python-pip clang -y
3. Not Using a Virtual Environment
Installing packages globally can lead to conflicts between projects. Always create a virtual environment to keep dependencies organized:
python -m venv myenv
source myenv/bin/activate
This keeps your Python setup clean and avoids compatibility issues.
4. Using the Wrong Python Command
Termux installs Python as python
, but some users mistakenly type python3
or python2
. Always verify the correct command with:
python --version
If you need Python 3 specifically, Termux already installs it by default.
5. Manually Editing Termux Files Without Understanding Them
Avoid manually modifying system files inside Termux unless you fully understand what you are doing. If something breaks, resetting Termux is often easier than troubleshooting:
rm -rf $HOME/.termux
6. Ignoring Storage Permissions
If you need Termux to access files outside its own directory, you must grant storage permissions:
termux-setup-storage
Without this, you may run into issues when trying to save or read files from shared storage.
From Pocket to Powerhouse
You don’t need expensive hardware to learn, build, or automate. As you’ve seen, setting up Python in Termux is simple, fast, and opens the door to a surprisingly capable dev environment—one that aligns perfectly with the FOSS philosophy of making tech accessible, portable, and free.
I built this guide because I’ve been where you are: trying to do more with less. And if it helped you get one step closer to that goal, I’d love to keep that momentum going.
👉 Subscribe to my newsletter at samgalope.dev/newsletter for more hands-on guides, practical tech workflows, and stories from the frontline of free and open source innovation.
Leave a Reply