{"id":82,"date":"2017-04-09T21:56:28","date_gmt":"2017-04-10T01:56:28","guid":{"rendered":"http:\/\/notebook.chaopricha.com\/?p=82"},"modified":"2017-04-25T11:31:20","modified_gmt":"2017-04-25T15:31:20","slug":"kivy-and-python-2-7x-on-windows-and-using-pip-to-install-wheels","status":"publish","type":"post","link":"https:\/\/notebook.chaopricha.com\/?p=82","title":{"rendered":"kivy and Python 2.7x On Windows (And Using Pip To Install Wheels)"},"content":{"rendered":"<p><a href=\"http:\/\/notebook.chaopricha.com\/wp-content\/uploads\/2017\/04\/Kivy-logo.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-83\" src=\"http:\/\/notebook.chaopricha.com\/wp-content\/uploads\/2017\/04\/Kivy-logo.png\" alt=\"\" width=\"212\" height=\"92\" \/><\/a><br \/>\nI have been tinkering with GoLang for a while and haven&#8217;t been using \u00a0Python until today I came across a very interesting Python framework called <a href=\"https:\/\/kivy.org\/#home\">kivy <\/a>(&#8220;Kee-vee&#8221;?) \u00a0It&#8217;s a very nice frame work that runs OpenGL with accelerated hardware to give you a smooth graphical user interface. \u00a0It also allows multi-touch for inputs. \u00a0It claims to be able to deploy on any platform including Android. \u00a0That&#8217;s very cool!.<\/p>\n<p>However, I ran into trouble quickly when I realize that I need Cython and other packages to use kivy. \u00a0My development environment is in Windows (I know I should use Linux, but we use Windows at work so I want to stay compatible with work). \u00a0Normally this is not a problem since I can go to my favorite <a href=\"http:\/\/www.lfd.uci.edu\/~gohlke\/pythonlibs\/\">Windows Binaries for Python Extension Packages webpage<\/a> maintained by Mr. Christopher Gohlke. \u00a0 He pretty much has everything you can think of for Windows binary packages. \u00a0It&#8217;s a lot cumbersome for me to go hunt down the Python sources for these packages and try to do the Python install myself. \u00a0It&#8217;s so much easier to go to a one stop shop like Mr. Gohlke&#8217;s page and just install the packages I want. The trouble is the page is now using Wheel files instead of the EXE files for the packages. This requires using PIP to do the installation and I have no idea at first how to do that. \u00a0Well, let me share with you what I found so that you can save time and frustration that require to use this amazing page of Python packages.<\/p>\n<p><strong>Install Python<\/strong><br \/>\nI&#8217;ll make the instruction as a brand new Python install. \u00a0I chose <a href=\"https:\/\/www.python.org\/downloads\/release\/python-2713\/\">Python 2.7.13<\/a>\u00a0(32-bit) since it&#8217;s the latest 2.7.x as of the time of this writing. \u00a0I didn&#8217;t pick Python 3.x because we use Python 2.7.x at work and again I want to be compatible with work. \u00a0Someday I&#8217;ll try Python 3.x but so far many libraries are in Python 2.7.x and not everything has migrated over to Python 3.x yet even though it&#8217;s been almost like a decade since Python 3.x came out (2008 I think). \u00a0This instruction should technically work for any versions but you just need to make sure you match the packages with the version you are using. \u00a0For me, it&#8217;ll be 2.7.x and 32-bit for all the packages.<\/p>\n<p>Now you need to make sure you have Python in you windows path variable or you can&#8217;t call python.exe from anywhere in the command line.\u00a0Click Start Menu and type into the search box &#8220;Edit the system environment variables&#8221;. \u00a0Click on the option that showed up in search under Control Panel result.<\/p>\n<p><a href=\"http:\/\/notebook.chaopricha.com\/wp-content\/uploads\/2017\/04\/edit-the-system-env.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-84\" src=\"http:\/\/notebook.chaopricha.com\/wp-content\/uploads\/2017\/04\/edit-the-system-env-300x248.png\" alt=\"\" width=\"300\" height=\"248\" srcset=\"https:\/\/notebook.chaopricha.com\/wp-content\/uploads\/2017\/04\/edit-the-system-env-300x248.png 300w, https:\/\/notebook.chaopricha.com\/wp-content\/uploads\/2017\/04\/edit-the-system-env-768x635.png 768w, https:\/\/notebook.chaopricha.com\/wp-content\/uploads\/2017\/04\/edit-the-system-env-363x300.png 363w, https:\/\/notebook.chaopricha.com\/wp-content\/uploads\/2017\/04\/edit-the-system-env.png 1012w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Now click on the &#8220;Environment Variables &#8230;&#8221; button under the System Properties screen that showed up.<br \/>\n<a href=\"http:\/\/notebook.chaopricha.com\/wp-content\/uploads\/2017\/04\/system-properties_edit-env.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-85\" src=\"http:\/\/notebook.chaopricha.com\/wp-content\/uploads\/2017\/04\/system-properties_edit-env-263x300.png\" alt=\"\" width=\"263\" height=\"300\" srcset=\"https:\/\/notebook.chaopricha.com\/wp-content\/uploads\/2017\/04\/system-properties_edit-env-263x300.png 263w, https:\/\/notebook.chaopricha.com\/wp-content\/uploads\/2017\/04\/system-properties_edit-env.png 409w\" sizes=\"(max-width: 263px) 100vw, 263px\" \/><\/a><\/p>\n<p>Click on the Path variable under System variables. \u00a0You might have to scroll down if you have a lot of stuff in your System variables like I do. \u00a0Then click &#8220;Edit &#8230;&#8221;<\/p>\n<p><a href=\"http:\/\/notebook.chaopricha.com\/wp-content\/uploads\/2017\/04\/System-varibles_change-path.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-86\" src=\"http:\/\/notebook.chaopricha.com\/wp-content\/uploads\/2017\/04\/System-varibles_change-path-300x284.png\" alt=\"\" width=\"300\" height=\"284\" srcset=\"https:\/\/notebook.chaopricha.com\/wp-content\/uploads\/2017\/04\/System-varibles_change-path-300x284.png 300w, https:\/\/notebook.chaopricha.com\/wp-content\/uploads\/2017\/04\/System-varibles_change-path-317x300.png 317w, https:\/\/notebook.chaopricha.com\/wp-content\/uploads\/2017\/04\/System-varibles_change-path.png 618w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><br \/>\n<\/a>For Windows 10 (with Anniversary update), Microsoft kindly added a new easier to read screen for the path variable management. \u00a0If you have a different version of Windows, you&#8217;ll have to look through the long line of paths separated by semicolons (;). \u00a0To add path, just add a semicolon to the last path in the line and then type in the new path you want. \u00a0For Windows 10, just click on &#8220;New&#8221; button to add path variables. \u00a0Add the following paths (defaulted by Python 2.7.x install. \u00a0If you install python in a different folder, you&#8217;ll have to use your custom path):<\/p>\n<pre>C:\\Python27\r\nC:\\Python27\\Scripts\r\n<\/pre>\n<p><a href=\"http:\/\/notebook.chaopricha.com\/wp-content\/uploads\/2017\/04\/Add-system-path.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-87\" src=\"http:\/\/notebook.chaopricha.com\/wp-content\/uploads\/2017\/04\/Add-system-path-300x285.png\" alt=\"\" width=\"300\" height=\"285\" srcset=\"https:\/\/notebook.chaopricha.com\/wp-content\/uploads\/2017\/04\/Add-system-path-300x285.png 300w, https:\/\/notebook.chaopricha.com\/wp-content\/uploads\/2017\/04\/Add-system-path-316x300.png 316w, https:\/\/notebook.chaopricha.com\/wp-content\/uploads\/2017\/04\/Add-system-path.png 527w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Now that the difficult part is done, time to move on to PIP install.<\/p>\n<p><strong>Download and Install PIP<\/strong><br \/>\nThis page shows you how to <a href=\"https:\/\/pip.pypa.io\/en\/latest\/installing\/\">install PIP<\/a> but I&#8217;ll explain how I did it. \u00a0Basically, right click on <a href=\"https:\/\/bootstrap.pypa.io\/get-pip.py\">get-pip.py<\/a>\u00a0and save it to some folder. \u00a0I put it in a C:\\python_packages\\ where I collect my packages to install.<\/p>\n<p>Launch a command prompt (Click start button, type &#8220;CMD&#8221; into the search box and hit enter.). \u00a0Get to the directory where you keep the get-pip.py then type:<\/p>\n<pre>python get-pip.py<\/pre>\n<p>If you correctly setup your path variables as I explained in the previous section then this should execute a pip package download. \u00a0Once this is done, you are almost ready to be able to use the Python wheel packages.<\/p>\n<p>Install Wheel Requirements to Use Mr. Gohlke&#8217;s packages<br \/>\nScroll \u00a0down and look for Pip package then download pip-9.01-py2.py3-none-any.whl from <a href=\"http:\/\/www.lfd.uci.edu\/~gohlke\/pythonlibs\/\">Gohlke page<\/a>\u00a0into any folder. \u00a0I recommend using the same folder where you put the get-pip.py script.<\/p>\n<p>[Update 4\/21\/2017]: You can get <a href=\"https:\/\/pypi.python.org\/pypi\/pip\">PIP<\/a> wheel from Python Package Index as well. \u00a0It&#8217;s a bit faster to download than Gohlke page. \u00a0Download the<\/p>\n<p>If your command prompt is still there and you are still in the same folder, you can type the following command:<\/p>\n<pre><span class=\"n\">pip<\/span> <span class=\"n\">install<\/span> <span class=\"n\">python.exe pip-9.0.1-py2.py3-none-any.whl\/pip install pip-9.0.1-py2.py3-none-any.whl<\/span><\/pre>\n<p>It should say something about the requirement is installed. If it doesn&#8217;t come up with error then you are good to go.<\/p>\n<p><strong>Installing Cython<\/strong><br \/>\nSince we have PIP installed and requirements met, we can try installing a package from Mr. Gohlke&#8217;s page. \u00a0Let&#8217;s try installing Cython since we&#8217;ll need that for Kyvi. \u00a0Look for <em>Cython-0.25.2-cp27-cp27m-win32.whl<\/em>\u00a0or whatever the latest version would be for Python 2.7.x and 32-bit. \u00a0Click on the link and you&#8217;ll be prompted for a save file location. \u00a0Again, I&#8217;ll put the package into the same folder we have been working with. \u00a0Kudos to Mr. Gohlke, The page is pretty well organized and kept up-to-date. \u00a0You can see from the file name what Python version and Windows version you need.<br \/>\n<a href=\"http:\/\/notebook.chaopricha.com\/wp-content\/uploads\/2017\/04\/python-binary-package-selection.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-88\" src=\"http:\/\/notebook.chaopricha.com\/wp-content\/uploads\/2017\/04\/python-binary-package-selection-300x251.png\" alt=\"\" width=\"300\" height=\"251\" srcset=\"https:\/\/notebook.chaopricha.com\/wp-content\/uploads\/2017\/04\/python-binary-package-selection-300x251.png 300w, https:\/\/notebook.chaopricha.com\/wp-content\/uploads\/2017\/04\/python-binary-package-selection-768x642.png 768w, https:\/\/notebook.chaopricha.com\/wp-content\/uploads\/2017\/04\/python-binary-package-selection-359x300.png 359w, https:\/\/notebook.chaopricha.com\/wp-content\/uploads\/2017\/04\/python-binary-package-selection.png 847w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><br \/>\nLaunch a command prompt again and navigate to our C:\\python_packages folder. Type the following command to install the Cython package:<\/p>\n<pre><span class=\"n\">pip<\/span> <span class=\"n\">install<\/span> <span class=\"n\">pip install Cython-0.25.2-cp27-cp27m-win32.whl<\/span><\/pre>\n<p>You should see this message if everything went well:<br \/>\n<a href=\"http:\/\/notebook.chaopricha.com\/wp-content\/uploads\/2017\/04\/successful-wheel-install.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-89\" src=\"http:\/\/notebook.chaopricha.com\/wp-content\/uploads\/2017\/04\/successful-wheel-install-300x42.png\" alt=\"\" width=\"300\" height=\"42\" srcset=\"https:\/\/notebook.chaopricha.com\/wp-content\/uploads\/2017\/04\/successful-wheel-install-300x42.png 300w, https:\/\/notebook.chaopricha.com\/wp-content\/uploads\/2017\/04\/successful-wheel-install-768x107.png 768w, https:\/\/notebook.chaopricha.com\/wp-content\/uploads\/2017\/04\/successful-wheel-install-500x70.png 500w, https:\/\/notebook.chaopricha.com\/wp-content\/uploads\/2017\/04\/successful-wheel-install.png 979w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><br \/>\nIf you get an error saying that pip is unrecognized then you need to make sure that you have the path C:\\Python27\\Scripts in your path variables. \u00a0Also make sure to close your command prompt and relaunch it any time you updated your path variables. \u00a0The command prompt doesn&#8217;t know about the new variables until you restart it.<\/p>\n<p>The generic command for installing any packages is just:<\/p>\n<pre>pip install SomePackage.whl<\/pre>\n<p>That&#8217;s it for installing Windows Binary wheels!<\/p>\n<p>Installing Kyvi<br \/>\nLet&#8217;s finish installing Kyvi now that we have Cython installed.<\/p>\n<p>First make sure that we have the latest pip wheel and setup tools using the following command:<\/p>\n<pre>python -m pip install --upgrade pip wheel setuptools<\/pre>\n<p>Install all the dependencies required to run Kyvi:<\/p>\n<pre>python -m pip install docutils pygments pypiwin32 kivy.deps.sdl2 kivy.deps.glew<\/pre>\n<p>*Install gstreamer:<\/p>\n<pre>python -m pip install kivy.deps.gstreamer<\/pre>\n<p>You could use a command line, but I kept running into a memory error issue maybe due to it being a large file (121 MB) and my firewall and anti-virus program so I just went to the <a href=\"https:\/\/pypi.python.org\/pypi\/kivy.deps.gstreamer\">PyPI site<\/a> to download the wheel. \u00a0I downloaded the appropriate version for my Python 2.7, 32-bit. ( kivy.deps.gstreamer-0.1.12-cp27-cp27m-win32.whl). \u00a0Once the file is downloaded to our usual location, run pip install:<\/p>\n<pre>pip install kivy.deps.gstreamer-0.1.12-cp27-cp27m-win32.whl<\/pre>\n<p>There shouldn&#8217;t be any error messages if everything went well. \u00a0Finally, install kivy itself:<\/p>\n<pre>python -m pip install kivy<\/pre>\n<p>Now let&#8217;s run an example python script using kivy to make sure that we have successfully installed kivy. \u00a0In command prompt,\u00a0type in this command:<br \/>\nc:\\Python27&gt;python c:\\python27\\share\\kivy-examples\\demo\\showcase\\main.py<\/p>\n<p>If everything was installed correctly, you&#8217;ll see a brief script execution in the command prompt and you&#8217;ll be greeted with the hello world demo:<br \/>\n<a href=\"http:\/\/notebook.chaopricha.com\/wp-content\/uploads\/2017\/04\/kivy-hello-world-demo.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-90\" src=\"http:\/\/notebook.chaopricha.com\/wp-content\/uploads\/2017\/04\/kivy-hello-world-demo-300x236.png\" alt=\"\" width=\"300\" height=\"236\" srcset=\"https:\/\/notebook.chaopricha.com\/wp-content\/uploads\/2017\/04\/kivy-hello-world-demo-300x236.png 300w, https:\/\/notebook.chaopricha.com\/wp-content\/uploads\/2017\/04\/kivy-hello-world-demo-768x605.png 768w, https:\/\/notebook.chaopricha.com\/wp-content\/uploads\/2017\/04\/kivy-hello-world-demo-381x300.png 381w, https:\/\/notebook.chaopricha.com\/wp-content\/uploads\/2017\/04\/kivy-hello-world-demo.png 802w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Now it&#8217;s time to have fun using kivy for your GUI. \u00a0I find it to be much prettier than Tk and much easier to use than Qt. \u00a0There are a lot of resources from kivy.org. \u00a0Here&#8217;s the link to building your <a href=\"https:\/\/kivy.org\/docs\/gettingstarted\/first_app.html\">first example app<\/a> in kivy.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I have been tinkering with GoLang for a while and haven&#8217;t been using \u00a0Python until today I came across a very interesting Python framework called kivy (&#8220;Kee-vee&#8221;?) \u00a0It&#8217;s a very nice frame work that runs OpenGL with accelerated hardware to &hellip; <a href=\"https:\/\/notebook.chaopricha.com\/?p=82\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,7],"tags":[],"_links":{"self":[{"href":"https:\/\/notebook.chaopricha.com\/index.php?rest_route=\/wp\/v2\/posts\/82"}],"collection":[{"href":"https:\/\/notebook.chaopricha.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/notebook.chaopricha.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/notebook.chaopricha.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/notebook.chaopricha.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=82"}],"version-history":[{"count":3,"href":"https:\/\/notebook.chaopricha.com\/index.php?rest_route=\/wp\/v2\/posts\/82\/revisions"}],"predecessor-version":[{"id":94,"href":"https:\/\/notebook.chaopricha.com\/index.php?rest_route=\/wp\/v2\/posts\/82\/revisions\/94"}],"wp:attachment":[{"href":"https:\/\/notebook.chaopricha.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=82"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/notebook.chaopricha.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=82"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/notebook.chaopricha.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=82"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}