Python enviroment setup


Todespreis

Member
Joined
Jun 16, 2021
Messages
83
Hey there! Now i have a working GP2X again and i want to code something in Python, i have the ported Python compiler for GP2X, i have a working Python 2 programm. The readme file on python makes me a bit confuzzed - how do i set up the compiler, that the device can actually read a .py program? I were already on gp2xwiki, but the link for Python enviroment doesn't work there anymore. Readme file says, i have to execute the data via shell script. But there is already a .sh data in /bin/. Do i have to modify it or write a 2nd file to run Python?
 
If the shell script doesn't end with something like 'python2 foo.py' then yes, it's no use for running your python program. If this is in /bin (a softlink to /usr/bin/ normally) then I doubt it's anthing to do with anything. You could write a script (presumably in the same folder as the python script) to launch the script in the python intepreter of your choice.

You can also make the first line of your python script look something like:
Code:
#!/usr/bin/env python2
Then you'll be able to run the python script like any other script, even a bash script. Just call it using './foo.py' assuming it's called foo.py and you're in the right folder first. I assume you have env in your /usr/bin, it's part of coreutils on my system here. If not there are still ways around that, but I tend to think it's better to use it if it's there. I'm assuming your python interpreter is somewhere on the path.
 
Last edited:
Thanks a lot! @Farox yes, I'm using this old Compiler for Python or i want to use it, i still wasn't able to run the programs properly. Is there any code example for GP2X environment, that I can find somewhere?
 
That post is... 16 years old!?! Was GP2X even out in 2005? Holy shit, okay, I think, i need to write a Compiler myself for it. Some professor teaches how to write a Compiler at our university, so maybe, he can help me
 
If you've compiled the "python" executable, normally you would run a .py file with `python myfile.py`, is GP2X different? Why would you need to write a compiler?
 
If I understood it correctly, there are 2 compilers, one of them is not accessable anymore and the other one has bugs. So I think, I have to write it myself, if I want to make anything with python. I have the one with bugs, but I can't get it working.
 
There's no compiler. Python isn't a compiled language.

I don't recall if you can issue terminal commands on the GP2X. Perhaps you have to write a script on another computer and shuttle that over to the GP2X but that should be too hard to achieve. I'd have thought a script containing just the word 'python' should be enough to launch the interpreter which should get you something like this in a terminal window:

Code:
Python 2.7.18 (default, Oct 22 2021, 10:51:06) 
[GCC 11.1.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>

That should be enough to test if it's basically working.
 
The boundary between compiler and interpreter has got a bit blurred nowadays. But since that program is conventionally called "the Python interpreter", people will understand better if you call it that too.

So, you have a Python interpreter that somebody else compiled, but it's not working?

You wouldn't be writing a new one anyway. In the worst case, you would be tweaking the source code, but probably not the parts related to what you learn about compilers in university, more the system glue parts around the edges.
 
Back
Top