Archive for the ‘Python Development’ Category

Installing Kivy on Windows

I found this really cool cross-platform toolkit for making GUIs from Python! It’s named Kivy. It’s available on Windows, Linux and Mac. (In case you’re not a developer, this is very cool!) The official installation instructions are here: https://kivy.org/docs/installation/installation-windows.html

However, I got an error when it tried to install gstreamer. I had to install that separately. What I did was download the wheel (.whl) file and install it first. After I did that, the rest of install worked fine. You can download the wheel file from here:
https://www.googledrive.com/host/0B1_HB9J8mZepNzZ5aW91Q0tJU2s/kivy.deps.gstreamer-0.1.5-cp27-none-win_amd64.whl

Open a command prompt/shell (of your choice), change to the directory where you downloaded the file and run:

pip install kivy.deps.gstreamer-0.1.5-cp27-none-win_amd64.whl

Note that I got an HTTP 502 error (yes, 502, or “temporary error”) for a while this morning, but then it worked. However, if that file does not exist (an HTTP 404 error), please check this page and download the appropriate file for your version of Windows and Python:
https://kivy.org/downloads/packages/simple/kivy-deps-gstreamer/

Finally, proceed with running everything from the official instructions. (Or everything that failed on you, if you’re sure what that was.)

Happy GUI development! ūüôā

Jasper on Raspberry Pi Running Raspbian Jessie

This will get Jasper running on your Pi. This method really works!¬†I’ve tested this and got it going on an RPi 2 running Raspbian Jessie.

The second script* prompts you for essential information and then it’s up to you to configure and use it.

All you need to do is download the two .sh files from my new project here: https://github.com/lelandg/Jasper-Installation-on-Raspbian-Jessie

See the repository for much more info.  Please report any errors that you may find there.

😎👍

*Technically it runs a Python script that prompts you for the info… but it appears¬†as though it happens as described above. It’s all smoke and mirrors anyway, right? So everyone expects a little magic now & then.🙂

Parallel Processing In Python the Easy Way!

The technical term for what we’re discussing today is¬†Decorated Concurrency. Don’t let this scare you!¬†😇¬†It’s just¬†a fancy (and concise) way of saying that, “We have a simple way to do parallel processing.”

Parallel processing, in turn, means that we can start multiple threads, as needed, in our program such that everything runs faster. Behind-the-scenes, on modern processors that have multiple cores, Python can run different processes on different cores. This lets a developer decide which processes will run the fastest because they have their own core. Or, at a higher level, which functions/methods are candidates for running on multiple cores.

I’ve known about parallel processing in Python for some time but it has always required making special function calls. No big deal ‚Äď especially since you have to write the code to be multithreaded in the first place ‚Äď but it would be nice if it was all a bit easier, right?!? Well now it is!!!¬†😎

The Deco (deco) project allows you to easily create code that takes advantage of parallel processing in Python. You simply do it with decorators!

If you’re new to programming, a decorator is just¬†something that you place in your code next to¬†a function/method/class, etc. definition. For example, the Deco project uses

@concurrent

and

@synchronized

tags. In Python you apply a decorator immediately before a function/method, etc. You can see some examples in the README.md file (that is shown to you by default) in this project: https://github.com/alex-sherman/deco (same link as above)

I expect you will be able to see some examples and some of my code very soon, as well.¬†😇

🙂👍

Bonus Linux tip: 

How to Isolate a CPU (core) and dedicate it to a specific task

To run a task on core 3 of a Raspberry Pi, or other Debian-based distro, including Ubuntu, simply add:

isolscpus=3

to the end of /boot/cmdline.txt. (There can be only one line in this file.)

And then run:

taskset -c 3 <your task here>

BTW, if you get a chance, please check out my new blog! http://lelandgreen.com
And if you like it, will you please share it around?¬†😎👍

Return top

Info

Section9 is a hackerspace based out of the Springfield Missouri area. For more information, please see the About Us page or find us on Facebook.