Tutorial for python on Linino

Hi all,

I feel like this should be easy to find - either I’m not using the right search terms or my googling skills have diminished rapidly.

I would like to create a python script on the Linux side of the Yun to handle some of the more processor-intensive aspects of my project. I am entirely new to both python and linux. I think I can hold my own with making the python script, but I can’t for the life of me figure out how to get the script onto linux. Is there a tutorial or set of instructions somewhere that I am missing?

Thanks,

Scott

If you are new to both Linux and Python, then you have quite a learning curve in front of you. But learning the world’s greatest operating system and programming language can be lot of fun. :slight_smile: Basically, what you want to do is SSH into your Yun, install an editor you are comfortable with using opkg (if it’s not already installed), write your Python script using the editor, save it to a file, then run the program with the "python " command. At least that’s how I’d do it. You could also type “python” without a file name and execute Python statements interactively, for the purpose of learning and testing. Once your script is running the way you want, you can start it from the arduino side if you like using the Bridge library.

Thanks for the reply. So you’re saying that I write/develop the code directly on the yun, instead of my (windows) pc like you would with the arduino side? That might be why I was having troubling figuring out how to move the code from one to the other. Is SSH the LuCI page that I get when I log into the Yun or is that something else?

No, you need an SSH client like putty. Using the password you configured in the Yun web interface and the “root” username, connect using the SSH client, specifying the Yun’s IP address and port 22.

Here's a little tutorial on getting into the Yun over SSH:

http://www.homautomation.org/2013/10/01/playing-with-arduino-yun/

Except you will use your SSH client instead of typing SSH at the command line.

Someone has installed openssh-sftp-server package which (with the proper utility: it depends on your operating system) allows you to see the yun as remote disk, allowing you to develop on your computer and have files immediately saved on the yun. My advice is to save on yun SD card

Correct, to do so from within Linux you can do as explained in:

[quote author=Federico Fissore link=topic=203191.msg1501967#msg1501967 date=1386703678] Someone has installed openssh-sftp-server package which (with the proper utility: it depends on your operating system) allows you to see the yun as remote disk, allowing you to develop on your computer and have files immediately saved on the yun. My advice is to save on yun SD card [/quote]

I did it on my Mac and it works great. This, combined with Brackets for doing JS and HTML programming is great (even doing some Python coding that way). After downloading and installing FUSE for OS X and SSHFS from here: http://osxfuse.github.io, you simply create a folder to map (here I used the folder named yun under my user) and start Terminal on OSX and do something like this:

sshfs root@arduino.local:/mnt/sda1/arduino/www /Users/yourname/yun/ -ocache=no -onolocalcaches -ovolname=yun

Or give Macfusion a try: http://macfusionapp.org

scottdrums89: I am entirely new to both python and linux.

That was me 3 months ago. Go through any of the basic Python tutorials. Then if you plan on doing anything with network connections go through Krondo's Twisted tutorial (library for Python networking). From there I just learned as I developed. I've been using an editor on my PC and then dumping onto the SD card to test every so often. Make sure whatever Python libraries you end up needing are installed on Linino. Coming from mostly C# background I found Python very strange at first but once you get the hang of it you'll be amazed how liberating it is.