TrapdoorSmoke
Posts: 81
Joined: Thu Nov 19, 2015 10:28 pm
Location: Scotland

Boot Straight to Python

Thu Jun 23, 2016 10:52 pm

I know this is possible but can I make a basic Linux Distribution that can boot straight to Python terminal.
Bootloader -> Linux -> INIT -> Python
Is that all I need, sure I can I write the INIT Program in C?

broe23
Posts: 903
Joined: Thu Jan 28, 2016 9:35 pm
Location: Central IL
Contact: Website

Re: Boot Straight to Python

Fri Jun 24, 2016 4:25 am

Python is a code language. You just do not boot to it, since it is always available when you boot up the Distro. What exactly are you trying to accomplish with this. If it is a script, just do a Google Search and you will find many posts about this subject already.
Ren: Now listen, Cadet. I've got a job for you. See this button? Ren: Don't touch it! It's the History Eraser button, you fool! Stimpy: So what'll happen? Ren: That's just it. We don't know. Maybe something bad, maybe something good.

stderr
Posts: 2178
Joined: Sat Dec 01, 2012 11:29 pm

Re: Boot Straight to Python

Fri Jun 24, 2016 5:10 am

TrapdoorSmoke wrote:I know this is possible but can I make a basic Linux Distribution that can boot straight to Python terminal.
Bootloader -> Linux -> INIT -> Python
Is that all I need, sure I can I write the INIT Program in C?
Are you trying to do some kind of bare metal thing, but you can't be because you say linux is booting first. You can just put python in your pi .bashrc file and automatically login to the prompt. This will put you in the python REPL, which is what you are asking for, I think.

User avatar
MarkHaysHarris777
Posts: 1820
Joined: Mon Mar 23, 2015 7:39 am
Location: Rochester, MN
Contact: Website

Re: Boot Straight to Python

Fri Jun 24, 2016 6:19 am

If you want a board that boots directly into Python then Micro-Python and the pyboard are for you!

I have one of these little boards (and they are tiny) and they are a fantastic micro-controller with Python running on the bare metal !

I soldered header pins onto mine, so its a bit taller, but you don't have to do that... it comes in a tidy little static free case (with rad micro-python stickers front and back) and the whole thing is powered from your gnu+linux PC (or other) using the micro-usb connector (it also is OTG ready) and you program it either on-board via terminal on your PC, or you program it on your PC and upload to the tiny pyboard using the OTG.

Check it out...
marcus
:ugeek:

User avatar
CarlRJ
Posts: 598
Joined: Thu Feb 20, 2014 4:00 am
Location: San Diego, California

Re: Boot Straight to Python

Fri Jun 24, 2016 9:31 am

TrapdoorSmoke wrote:I know this is possible but can I make a basic Linux Distribution that can boot straight to Python terminal.
Bootloader -> Linux -> INIT -> Python
If what you want is to have some specific Python script run when the system boots up, you can put a call to it at the end of /etc/rc.local (there are fancier newer ways to do this, but the old way still works). If what you really want is a system that boots up to the ">>>" prompt of Python's REPL, then you could use the "raspi-config" utility to set "Boot Options" to "Console Autologin", then add an entry to the end of your ~/.profile script to run Python. But, a) this isn't very practical (because then the only thing you can do it test out bits of python code, you can't actually write and save anything substantial, and b) this will be fairly hard to undo - because now restarting the Pi will always bring you to Python's ">>>" prompt - and it's quite difficult to undo the changes to your .profile from there.

(Oh, and MicroPython is pretty cool - watched someone give a short talk this evening about running MicroPython on a very cheap ESP8266 board, and that's a system where you really can connect to it and get Python's ">>>" prompt.)

User avatar
MarkHaysHarris777
Posts: 1820
Joined: Mon Mar 23, 2015 7:39 am
Location: Rochester, MN
Contact: Website

Re: Boot Straight to Python

Fri Jun 24, 2016 9:40 am

CarlRJ wrote: (Oh, and MicroPython is pretty cool - watched someone give a short talk this evening about running MicroPython on a very cheap ESP8266 board, and that's a system where you really can connect to it and get Python's ">>>" prompt.)
Oh, and if I wasn't clear, with the pyboard you can connect to it and get python's REPL prompt
>>>

... and control its GPIO pins (pwm, and all the rest) right there interactively !
marcus
:ugeek:

TrapdoorSmoke
Posts: 81
Joined: Thu Nov 19, 2015 10:28 pm
Location: Scotland

Re: Boot Straight to Python

Fri Jun 24, 2016 9:49 am

Just wanted to make a OS with Python shell because the shell is much like bash

User avatar
MarkHaysHarris777
Posts: 1820
Joined: Mon Mar 23, 2015 7:39 am
Location: Rochester, MN
Contact: Website

Re: Boot Straight to Python

Fri Jun 24, 2016 12:18 pm

TrapdoorSmoke wrote:Just wanted to make a OS with Python shell because the shell is much like bash
hi, the Python REPL (Read Execute Print Loop) is not a shell.

... because unlike a shell (like bash for instance) the Python REPL does not pass commands on to the system. The Python REPL is a language interpreter designed to read, execute, print, and repeat; whereas the shell is designed to 'filter' one way or another and then pass commands on to the system kernel-- including launching other programs.

An OS is neither. The shell interfaces with the OS. Python runs on the OS... the bash shell hands instructions off to the OS (including telling the OS to launch other programs). The OS manages the system's resources.

Too many people believe the interface is the OS...

The OS is NOT the windowed graphical interface, nor is it the shell. Interfaces should not be confused with the OS.
marcus
:ugeek:

Return to “General discussion”