Installing Python2

Greetings. I have a script that i usually run on my devices with "python2". However, executing this script with python3 gives errors.
I installed openwrt on one of my devices and have been trying to install python2 but to no avail (i got python3 to install).
Question: How can i get python2 installed on my openwrt device so that i can execute my python script?

Python 2 has been completely deprecated and is actually not (easily) available on many platforms now. I'd recommend working to resolve the errors in your script. Many of the errors can be resolved fairly easily by adjusting the syntax and/or importing some modules.


Thanks for your reply. So there isn't any "community" repository or way i can get python2 installed :frowning: ?

Im not versed in programming so fixing the errors may be difficult. someone on a chat got the script to execute for me on python3 but one part of it doesn't work as it should and he said he will be unable to assist further with the issue i am getting. so i am stumped there

I don't know about python2 on OpenWrt, but yeah, it's likely to be pretty tricky. You could theoretically compile it yourself.

Regarding fixing python 3 script issue, searching the web (especially stackexchange) is a great way to figure it out.... or, post questions on python related sites (including stackexchange).

1 Like

ok ill see if i can find a way to compile python2.
thanks for the assistance thus far!

hopefully someone can help with my issue.

i am seeing the package here. "python-light" shows python2 but how can i get it installed along with dependencies? I put the URL in the opkg config file but i get error "pkg_hash_fetch_best_installation_candidate: Packages for python-light found, but incompatible with the architectures configured"

sorry for the questions but im new to openwrt

You could try automated translation - for simple scripts that's often enough.

Seriously - don't waste your time to get an EOL programming language running.
The package repository you linked to is of an OpenWrt version that's also EOL...


ah ok. im gonna try the link you sent. thanks

edit: thats 2to3 which i tried already but it doesnt work. the script spits out some errors when i run the new versions that 2to3 produces

What version of OpenWrt are you using and on what platform? I agree that it is not worth trying to spend any time on getting python 2 working.

this is what im using. i have an android box that i was going to put to use to act as a server. the last part i need working is the script lol

Oh. And by the looks of it, you’re probably using some custom fork of OpenWrt and not the official version. You might ask the vendor/maintainer for help. But it is still not worth investing time in py2

Lets take a step back -- what are you trying to run and why does it need python2?

sigh :frowning: ok. you've been a great help. thanks again

this is the code. when i use python3 i get error. i tried to convert with 2to3 and the script executes but not as it should. so i just wanted to use python2 again because i know it works

Looking at the code, (and running it through converter), I think that you just need to change all print statements to print functions by adding ( ) to 10 lines.
In style of

    print "\n:-------PythonProxy-------:\n"
    print "Listening addr: " + LISTENING_ADDR


    print("Listening addr: " + LISTENING_ADDR)

And apparently also "thread" on the first line needs to be "_thread":
import socket, threading, _thread, select, signal, sys, time, getopt

1 Like

It looks like a simple http proxy server, why not use one of the supported ones instead?

1 Like

thanks much. will look into it!

im reading up on it now. you all have been a great help and im grateful. will report back when the issue is fixed!

again to everyone...thanks