The answer to the question " How to create and run python program in Android device? " Is here.
To run Python programs in android using Termux requires the installation of two termux packages.
- python:
Python package in Termux refers to a collection of Python modules or libraries that can be installed and used in the Termux terminal emulator app for Android. These packages can be used to extend the functionality of Python and perform various tasks such as web scraping, data analysis, and machine learning. Some popular Python packages that can be installed in Termux include NumPy, Pandas, and Scikit-learn.
- Nano :
Text Editor to create a file
WHAT We will learn ?
- Termux Installation
- Update and Upgrade Termux
- Install packages for Python
- Develop Simple Python Program using Nano text editor in Termux
- Run Python Program
- Tips – Solution for “E: Unable to locate package clang” Error
Watch and Learn:
Before we learn "Python on Android: How to Run Programs with Termux," let's take a look at Some Important Termux commands we must remember:
- To clear all screen content run the command.
$ clear
- To find current working directory.
$ pwd
- To change our current working directory to another directory. Here I’m moving in /java directory/folder.
$ cd /java
- If you want one directory/folder to move
$ cd..
- If you want to back two directories use.
$ cd ../../
- To Create New File: To Create New Directory/Folder use mkdir commad Stands for make a new directory.
$ mkdir <new-directoy-name>
- To Delete Directory/Folder in Termux
$ rmdir <directory-name>
- To delete File
$ rm <file-name>
Check this one: Amazing fact of Switch statement in C
Here is How You Can Write and Run Python Programs on Your Android Devices
Step 1: Install Termux from Google Play
Step 2: Now Update and Upgrade Termux
- Open Termux
- To Update Termux type command
apt update
- To Upgrade Termux type command
$ apt upgrade
Step 3: Open Termux app and install Python and nano package to create and run python
$ pkg install python
- This will install python package
$ pkg install nano
- This command will install nano text editor if not available.
Step 4: Run and learn Pyton by using python interpreter.
- Once the installation is complete, you can run Python by typing python at the Termux prompt and pressing Enter. This will start the Python interpreter, which allows you to run Python code interactively.
- Here is an example of how you can use the Python interpreter to print "Hello, World!" to the console:
- To exit python interpreter type "exit()" command.
Step 5: To create Python program file with .py extension
- Type $ nano firstpractical.py
- This will create firstpractical.py file and open file in nano text editor.
- Now write a simple Python program in nano text editor as given below.
print("Welcom to Computer Bits Daily")
- Press Ctrl + s to save file and Ctrl +x to exit nano text editor.
Step 6: To run your Python program
$ python firstpractical.py [ type this and press enter]
- You will get output “Welcom to Computer Bits Daily”
Step 7: To exit Termux type command
$ exit
Possible solution for “E: Unable to locate package clang” Error
- Solution 1: use $ apt update command and then try to install package
- Solution 2: use $ pkg upgrade command and then try to install package
- Solution 3: use $ termux-change-repo command and then try to install package
- Solution 4: use $ pkg install root-repo command and then try to install package
- Solution 5: use $ termux-setup-storage command and then try to install package
Free Full C Programming Course With best Android app: Computer Courses Computer Bits Daily
0 Comments