kivy 1.9.1 + win7 + Python 3.4.3 + freezing code = creating one „exe“ from your kivy project

How can I deploy my application to the „customer“ so he does not have to install anything else? There are some alternatives with comparison on this site. Here I will show you a way how to freeze your kivy project via pyInstaller under win7.

#and now it’s working !!

pyInstaller

Is now availible also for Python 3, with GPL license.

According to documentation here you should do the following:

  • Install pyInstaller
  • Through kivy34.exe
  • Create spec file by pyinstall
    $ cd dir\where\I\want\to\build
    $ pyinstall --name project-name ..\path\to\python\file.py
  • Than to meddle with the (.spec) file found in the current dir
  • You must install required packages:
    ('pygame', 'text_pygame', 'LabelPygame'),
        ('sdlttf', 'text_sdlttf', 'LabelSDLttf'),
        ('pil', 'text_pil', 'LabelPIL'),
  • installed pygame – didnt help with
    pil – ImportError: cannot import name ‚ImageFont‘
  • recompiled the latest kivi source code from git master
    • as in this instructions
    • if 1.9.1 and on computer with integrated GPU (not dedicated) you may run into error:
      • Minimum required OpenGL version (2.0) NOT found!
    • don’t warry, its just not detecting one of the modules, to solve you just need to implicitly turn it of
    • just add this snippet into your App class build function:
      def build(self):
         Config.set('graphics', 'multisamples', 0) 
         return RootWidget()
  • started Kivy3.4.bat
    $ >pyinstaller --name touchtracer "..\kivy34\examples\demo\touchtracer\main.py"
    • name should be same as the top most directory
  • correct the spec file (25-10-2015) „as follows“
    http://pastebin.com/YKYVgLX4
  • started Kivy3.4.bat
    $ >pyinstaller touchtracer.spec

The original steps rewritten by me – does not include the OpenGL glitch solving  (25-10-2015)

Trouble makers

  • you should not copy the kivy directory from official distribution inside your projects directory to start it – if it asks for missing files the spec file correction is not right

Napsat komentář

Vaše emailová adresa nebude zveřejněna. Vyžadované informace jsou označeny *