How To Install Python2 And Python3 On Termux?

    - Advertisement -
    python in termux

    Many users have experienced difficulty installing python2 and python3 on Termux. So, in this blog, I will share a step-by-step guide on how you can install python2 and python3 in Termux.

    Why install python2 when there is python3 available?

    Many programs are written using python2, and If one will try to run those programs in python3, they will show errors like Indentation error. For that, one needs to have python2 installed to run the programs that require python2.

    How to install both python2 and python3 in Termux?

    Follow these simple commands to install python2 and 3 in your Termux

    • apt update && apt upgrade – This will update the list and also upgrade the available packages
    • apt install python – Installs Python3
    • apt install python2 – Installs Python2
    apt update && apt upgrade
    apt install python
    apt install python2

    How to use python2 and python3 ?

    If you type python, Termux will automatically open that program with python3. To use python2, you need to type python2 This way, you can specifically tell Termux to use python2 instead of the default python3 version.

    The same goes for pip, if you use pip install example, this will automatically use pip version 3 to install packages. To install packages from pip version 2, use pip2 install example.

    This will allow you to use both python2 and python3, according to your need. To use python2, type python2, and for python 3, type python3, or type python to use python3 by default.

    Installing any version of python in termux

    You can install any python version by specifying the version before installing it.

    For example: To install python v3.9.4, you can enter the command apt install python=3.9.4. With this command, it will search for a specified version. If that version is available, the package manager will install it. If it is not available, you’ll get an error indicating that “this version cannot be found.”

    So this is how you can install a specified python version and use it according to what you need. Give it a try, and let me know if this helps.

    - Advertisement -

    Read Also : Top 5 Best Information Gathering Tools For Termux

    - Advertisement -

    Recent Articles