Giuseppe Parrello

 

How to install the Python interpreter


In this page I will describe how to install the Python interpreter on a router (Asus RT-AC56U) - we use some Entware packages, so please refer to this page on how to install Entware on a router.
On Entware, Python interpreter is available in 2.x and 3.x releases. Here, in this page, we will explain how to install both of them. Keep in mind that on this website, several pages will refer to package "PIP", so we will provide you with simple instructions on how to install the above-mentioned package "PIP" without installing all the Python package.


How to install the Python interpreter - release 2.x

To install only the basic Python package, use the command line "opkg install python", this comand will install the Python interpreter and the most important libraries.
To install only the "PIP" package, use the command line "opkg install python-pip", this comand will install the Python interpreter and the most important libraries, as well as the "PIP" package.
To install the Python interpreter and all its libraries, firstly we have to know which are the packages to be installed; use the command line "opkg list | grep -i python-" to have a list of packages to be installed and run a command "opkg install [package name]" to install each one of them. The most practical method is to create one script in order to install all packages. Here is a simple script example.

#!/bin/sh

opkg install python
opkg install python-asn1crypto
opkg install python-base
opkg install python-certifi
opkg install python-cffi
opkg install python-cloudprint
opkg install python-codecs
opkg install python-compiler
opkg install python-crypto
opkg install python-cryptography
opkg install python-ctypes
opkg install python-cups
opkg install python-curl
opkg install python-dateutil
opkg install python-db
opkg install python-decimal
opkg install python-distutils
opkg install python-email
opkg install python-enum34
opkg install python-gdbm
opkg install python-idna
opkg install python-ipaddress
opkg install python-light
opkg install python-logging
opkg install python-multiprocessing
opkg install python-mysql
opkg install python-ncurses
opkg install python-openssl
opkg install python-pip
opkg install python-pip-conf
opkg install python-ply
opkg install python-pyasn1
opkg install python-pycparser
opkg install python-pydoc
opkg install python-pyopenssl
opkg install python-requests
opkg install python-setuptools
opkg install python-six
opkg install python-sqlite3
opkg install python-unittest
opkg install python-urllib3
opkg install python-xml

How to install the Python interpreter - release 3.x

To install only the basic Python package, use the command line "opkg install python", this comand will install the Python interpreter and the most important libraries.
To install only the "PIP" package, use the command line "opkg install python3-pip", this comand will install the Python interpreter and the most important libraries, as well as the "PIP" package.
To install the Python interpreter and all its libraries, firstly we have to know which are the packages to be installed; use the command line "opkg list | grep -i python3-" to have a list of packages to be installed and run a command "opkg install [package name]" to install each one of them. The most practical method is to create one script in order to install all packages. Here is a simple script example.

#!/bin/sh

opkg install python3
opkg install python3-asn1crypto
opkg install python3-asyncio
opkg install python3-base
opkg install python3-cffi
opkg install python3-cgi
opkg install python3-cgitb
opkg install python3-codecs
opkg install python3-cryptography
opkg install python3-ctypes
opkg install python3-dbm
opkg install python3-decimal
opkg install python3-dev
opkg install python3-distutils
opkg install python3-email
opkg install python3-gdbm
opkg install python3-idna
opkg install python3-lib2to3
opkg install python3-light
opkg install python3-logging
opkg install python3-lxml
opkg install python3-lzma
opkg install python3-multiprocessing
opkg install python3-ncurses
opkg install python3-openssl
opkg install python3-pip
opkg install python3-ply
opkg install python3-pyasn1
opkg install python3-pycparser
opkg install python3-pydoc
opkg install python3-pyopenssl
opkg install python3-requests
opkg install python3-setuptools
opkg install python3-six
opkg install python3-sqlite3
opkg install python3-unittest
opkg install python3-xml
opkg install python3-yaml

Since the executable of the Python interpreter, release 3.x, is"python3", I suggest to create a simple script in order to run the Python interpreter with command "python". Here is a simple script example, we can name the file "/opt/bin/python".

#!/bin/bash

/opt/bin/python3 $1 $2 $3 $4 $5 $6 $7 $8 $9

How to remove the Python interpreter - release 2.x

To remove the Python interpreter and all its libraries, firstly we have to know which are the packages to be removed; use the command line "opkg list_installed | grep -i python-" to have a list of packages to be removed and run a command "opkg remove [package name]" to remove each one of them. The most practical method is to create one script in order to remove all packages. Here is a simple script example.

#!/bin/sh

opkg --force-depends remove python-xml
opkg --force-depends remove python-asn1crypto
opkg --force-depends remove python-base
opkg --force-depends remove python-certifi
opkg --force-depends remove python-cffi
opkg --force-depends remove python-cloudprint
opkg --force-depends remove python-codecs
opkg --force-depends remove python-compiler
opkg --force-depends remove python-crypto
opkg --force-depends remove python-cryptography
opkg --force-depends remove python-ctypes
opkg --force-depends remove python-cups
opkg --force-depends remove python-curl
opkg --force-depends remove python-dateutil
opkg --force-depends remove python-db
opkg --force-depends remove python-decimal
opkg --force-depends remove python-distutils
opkg --force-depends remove python-email
opkg --force-depends remove python-enum34
opkg --force-depends remove python-gdbm
opkg --force-depends remove python-idna
opkg --force-depends remove python-ipaddress
opkg --force-depends remove python-light
opkg --force-depends remove python-logging
opkg --force-depends remove python-multiprocessing
opkg --force-depends remove python-mysql
opkg --force-depends remove python-ncurses
opkg --force-depends remove python-openssl
opkg --force-depends remove python-pip
opkg --force-depends remove python-pip-conf
opkg --force-depends remove python-ply
opkg --force-depends remove python-pyasn1
opkg --force-depends remove python-pycparser
opkg --force-depends remove python-pydoc
opkg --force-depends remove python-pyopenssl
opkg --force-depends remove python-requests
opkg --force-depends remove python-setuptools
opkg --force-depends remove python-six
opkg --force-depends remove python-sqlite3
opkg --force-depends remove python-unittest
opkg --force-depends remove python-urllib3
opkg --force-depends remove python

How to remove the Python interpreter - release 3.x

To remove the Python interpreter and all its libraries, firstly we have to know which are the packages to be removed; use the command line "opkg list_installed | grep -i python3-" to have a list of packages to be removed and run a command "opkg remove [package name]" to remove each one of them. The most practical method is to create one script in order to remove all packages. Here is a simple script example.

#!/bin/sh

opkg --force-depends remove python3
opkg --force-depends remove python3-asn1crypto
opkg --force-depends remove python3-asyncio
opkg --force-depends remove python3-base
opkg --force-depends remove python3-cffi
opkg --force-depends remove python3-cgi
opkg --force-depends remove python3-cgitb
opkg --force-depends remove python3-codecs
opkg --force-depends remove python3-cryptography
opkg --force-depends remove python3-ctypes
opkg --force-depends remove python3-dbm
opkg --force-depends remove python3-decimal
opkg --force-depends remove python3-dev
opkg --force-depends remove python3-distutils
opkg --force-depends remove python3-email
opkg --force-depends remove python3-gdbm
opkg --force-depends remove python3-idna
opkg --force-depends remove python3-lib2to3
opkg --force-depends remove python3-light
opkg --force-depends remove python3-logging
opkg --force-depends remove python3-lxml
opkg --force-depends remove python3-lzma
opkg --force-depends remove python3-multiprocessing
opkg --force-depends remove python3-ncurses
opkg --force-depends remove python3-openssl
opkg --force-depends remove python3-pip
opkg --force-depends remove python3-ply
opkg --force-depends remove python3-pyasn1
opkg --force-depends remove python3-pycparser
opkg --force-depends remove python3-pydoc
opkg --force-depends remove python3-pyopenssl
opkg --force-depends remove python3-requests
opkg --force-depends remove python3-setuptools
opkg --force-depends remove python3-six
opkg --force-depends remove python3-sqlite3
opkg --force-depends remove python3-unittest
opkg --force-depends remove python3-xml
opkg --force-depends remove python3-yaml
opkg --force-depends remove python-pip-conf