In this installment of our Onion Omega2 tutorial series, we will cover the basic steps necessary to install and run python on the Omega2 or Omega2+


Hi, I'm Dave here at Core Electronics and in this quick video. I'm going to show you how to install Python on the Onion Omega2.

The first step is to connect to the Onion Omega using SSH. If you're using Mac or Linux you already have everything you need just open up the terminal and run SSH. If you're using Windows, you'll need to download and install putty.

You can connect to your board making sure that both your PC and the onion Omega are on the same Wi-Fi network, with this address. Check SSH and make sure port says 22.

All right it asks us for our login while login as root and the default password is onion ear. First thing we need to do is a no OPKG update to up state the installer files.

Now we can install python, but we do have a couple of choices, there's two different versions of Python, Python 2.7 which is just normally known as Python and Python3. I'm not going to go into which one's better here there's plenty of information on that all over the Internet, but I'll be using Python2. However, there's another choice whether we use Python or Python light - light is pretty much exactly the same, but most of the extra modules and packages aren't installed by default. On the onion Omega 2 there is pretty limited space so there is an argument for using Python light but since I'm not doing anything super complicated with this board I'm going to just go ahead and install the full Python2. Install command as opkg install python, if you wanted to do Python you'd say opkg install python3.

Okay now pythons finished installing, before we move on we should also cover how to install extra modules and packages which with programming with Python at some point you will need. We can install some modules and packages using opkg and we can list the ones available with this command opkg list pipe grep Python. Right a lot of word salads there but it is a full list of all the Python modules available through correctly through IP opkg. If you wanted to see just the module specific to Python3. You can run this command it's the same one before but Python3 instead of Python and there's a list of the modules available for Python3. To show you how to install a module opkg install and I’m going to install py Onion GPIO take note for the case there. This is the module that lets us control the Omegas GPIO pins with our Python program most users are probably going to want this module at some point so I'm going to install it now. Okay and that's completely installed a more robust method for installing modules is to use a program called pip, pip is like another package manager except it's exclusively for Python modules and packages. To install module using pip use the following command pip install and then the module name. I'm going to install the simple math module and there's the simple math module installed very easily. If you run into a certain error when trying to install a module using pip and you can see that error on the web page of this tutorial you may need to run the following command. Pip install double - upgrade setup tool and that's how you install modules using pip.

The last thing we're going to do in this video is write a simple hello work program to test it pythons working correctly. We'll need a text editor for this the Omega does include VI, but I find it very user unfriendly so I'm going to install if you get a Nano with opkg install Nano.

Okay now let's install let's create a directory to put our Python program in I'm going to put it in route / Python. Let's change into that directory, it should be empty, excellent. Now we can create a new Python file with Nano and it's open down here. First thing I'll do is that a comment to let us know what this program does, and we need our one command, which is print single quotation mark hello world from electronics. And then close the single quotes press control X to exit, it's asking down the bottom if we want to save the modified buffer. Hit Y for yes and enter, to use the name we open the file with. Now to run the file program I just type Python and then the file name and there we are. Hello world from core electronics.

So that's how you set up and get started with python on your onion Omega 2. If you have any questions or issues as always don't hesitate to leave a comment or hit over to our forum.



Please continue if you would like to leave feedback for any of these topics:

  • Website features/issues
  • Content errors/improvements
  • Missing products/categories
  • Product assignments to categories
  • Search results relevance

For all other inquiries (orders status, stock levels, etc), please contact our support team for quick assistance.

Note: click continue and a draft email will be opened to edit. If you don't have an email client on your device, then send a message via the chat icon on the bottom left of our website.

Makers love reviews as much as you do, please follow this link to review the products you have purchased.