2018-07-27

Python With Kivy in Debian

A lot of concepts there...  Why python?  Because it's so simple a computer language that it's usually a first language for learning programming.  Yet, it's so developed and complete as I see it.  Kivy?  Well, it's a python library used in developing mobile apps and other multitouch application software with a natural user interface (NUI); it can run on Android, iOS, Linux, OS X, and Windows, and it's free and open source.* Debian is there because it's the OS I'm using, and I'm learning some tricks while installing Kivy in it.  The insight why I chose Debian is covered in a previous post.

Installing python is simple and straightforward, but you have to choose python3 because python (as python2) is already installed.  This is not a problem in other OS's where python is not installed by default, and installing python will install the latest available version (python 3.x).  Installing kivy may be straightforward in other OS's, but it demands some patience in Debian as I experienced.  This is due to the many dependencies which usually conflict with the more updated versions of others.  The latest version of Cython, e.g., is not compatible with kivy (cython 0.28.4) so I had to force install the 0.28.2 version.

python powered
Installing kivy should be very easy and as simple as issuing the command 'sudo apt install python3-kivy' and giving your password.  The dependencies are automatically installed, but when you import kivy, errors glare at you, saying some services are not present or some files are missing.  So I decided to use pip (python package installer), issuing the command 'sudo apt install python3-pip', but using pip directly does not work!  The command 'sudo pip install kivy' fails (pip3 may be used because I'm using python3).  I searched the web and I found out that I had to install some packages that are not automatically installed, namely python3-dev, libsdl2-image-dev, libsdl2-mixer-dev, libsdl2-ttf-dev, python3-virtualenv and libgstreamer1.0-dev.  So I uninstalled kivy to avoid conflicts, and installed all those files.  Kivy still doesn't work as above so I used another trick so that python itself will do the installing.  I guess the package will just work for myself (because I didn't use sudo).  I issued the commands:

python3 -m pip install -I Cython==0.28.2  #install a particular version
python3 -m pip install kivy

Now my python works fine with kivy, but I only tested it with my scripts.  Now instead of searching the web for some apps (maybe for some calculations) that are specific to a problem, I make the programs.  Isn't that cool?  When I decide to deploy some apps (for Android and other platforms), I bet I'll have some problems but I'm sure the web is there to help, as before.

No comments: