Do you want to install Python in Termux and use it? If you are searching for how to install Python in Termux then you are in the right place because in this article I will explain how to install Python in Termux and how you can use it. You will also learn to install Python 2 and Python 3.
After installing Python in Termux you can make your own programme and run other Python scripts on your Android device with the help of Termux, you can basically install all Python modules because Python will install with pip in Termux. You can use pip to install any Python module that is available on PyPI.
How to install Python in Termux?
To install Python in Termux you need to download the latest version of Termux from F-droid. After that, open Termux and then you need to run some required commands to update and upgrade Termux packages. Here are the commands:
apt update
apt upgrade -y
These commands will update and upgrade your Termux packages. After that you are ready to install Python in your Termux. Now let’s see the simple command to install Python in Termux:
pkg install python -y
Run this simple command to install Python in Termux.
Check Python Version:
After successfully installing Python in Termux, the next step is to check the version of Python that you installed in Termux. To check the version you just need to run the following command:
python --version
Check Pip Version:
Pip is a package installer for Python with the help of pip you can install any Python module that is available on PyPi (Python Package Index). It’s important to check the pip version on Termux to run Python programmes or Python scripts smoothly. Run the following command to check the pip version in Termux:
pip --version
how to install python 2 in termux?
Python 2 has ended, which means there’s no official support or updates, therefore I highly recommend you use Python 3 for new projects. If it necessary to use Python 2 then you can install Python 2 in Termux by running the following commands:
pkg install python2
verify the version:
You can check the Python 2 version by running the following command:
python2 --version
check pip version:
You can run the following command to check the pip version of Python 2 in Termux:
pip2 --version
how to install python 3 in termux?
If you want to install Python 3 in Termux then both the Python and Python 3 installation commands are the same.
pkg install python
Verify Python 3 installation:
You can verify that Python 3 is installed correctly by checking its version.
python3 --version
Check Pip Version:
Run the following commands to check the pip version of python 3:
pip3 --version
Single line command:
You can use this one line command to install Python, Python 2 and Python 3 with one click.
apt update && apt upgrade -y && pkg install python python2 python3 -y
Conclusion:
In this post, we learn about how to install Python in Termux. We install Python, Python 2, and Python 3 with just a few commands. Python is a high level and most popular programming language. You can use Python in Termux to create programmes, run Python scripts and you can do more with Python. You can also install and use any Python package with the help of pip.
FAQ:
How to install python packages in Termux?
If you want to install Python packages in Termux then you can install any Python package in Termux with the help of pip, like pip install {packages name}
. For example, if you want to install Numpy:
pip install numpy
Replace the package name that you want to install.
How can I install Python on termux?
To install Python in Termux, you can use this single line command:
apt update && apt upgrade -y && pkg install python python2 python3 -y
This command will automatically install Python, Python 2 and Python 3 in a single click.