How to create kivy applications for desktop in linux?

708 views
Skip to first unread message

coutinh...@gmail.com

unread,
Apr 20, 2021, 3:11:57 PM4/20/21
to Kivy users support
Good afternoon people.
I want to create in linux (Ubuntu 20.04) an application in Kivy and KivyMD to work independently, if it were on Windows it would be an .exe

It happens that I using pyinstaller it creates the file and in the Dist folder, but when running it presents the following message:

There is no application installed for "shared library" files. Do you want to search for an application to open this file?

I tried to use the model quoted by kivy itself, https://kivy.org/doc/stable/guide/packaging-windows.html
but it only shows packages for Windows, Mac and OsX

I tried to use the Windows model but it returned the error below:

   File "DeskShop.spec", line 3, in <module>
     from kivy_deps import sdl2, glew
ModuleNotFoundError: No module named 'kivy_deps'

How to create kivy applications for desktop in linux?

Elliot Garbus

unread,
Apr 20, 2021, 9:01:00 PM4/20/21
to kivy-...@googlegroups.com

Here is the spec file I use on Windows.  Something similar will work on Linux.  I create a directory under the main project director called MyProjectNameDist, and put the spec files there.  This is important when looking at the directories below.  I switch to the directory that contains the spce file and then run pyinstaller.

 

 

# -*- mode: python -*-

import os

from kivy_deps import sdl2, glew

spec_root = os.path.abspath(SPECPATH)
block_cipher = None
app_name = 'Yout App Name'
win_icon = '../Images/your_design_icon.ico'

a = Analysis(['../main.py'],
             pathex=[spec_root],
             datas=[('../*.kv', '.'),
                    ('../Images/*.png', './Images')],
             hiddenimports=['win32timezone'],
             hookspath=[],
             runtime_hooks=[],
             excludes=[],
             win_no_prefer_redirects=False,
             win_private_assemblies=False,
             cipher=block_cipher,
             noarchive=False)
pyz = PYZ(a.pure, a.zipped_data,
             cipher=block_cipher)
exe = EXE(pyz,
          a.scripts,
          [],
          exclude_binaries=True,
          name=app_name,
          debug=False,
          bootloader_ignore_signals=False,
          strip=False,
          upx=False,
          console=False,
          icon=win_icon)
coll = COLLECT(exe,
               a.binaries,
               a.zipfiles,
               a.datas,
               *[Tree(p) for p in (sdl2.dep_bins + glew.dep_bins)],
               strip=False,
               upx=False,
               name=app_name)

--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/cdbdcd19-9423-4e4a-8f46-f67091cf4d50n%40googlegroups.com.

 

Elias Coutinho

unread,
Apr 20, 2021, 10:50:31 PM4/20/21
to kivy-...@googlegroups.com
This is for Windows, and to generate an application that runs on Linux? What's the tip?



--
Elias Coutinho.
Aprender sobre alguns assuntos é fundamental.
Aprender sobre Deus é indiscutivelmente o melhor conteúdo.

Elliot Garbus

unread,
Apr 20, 2021, 11:08:36 PM4/20/21
to kivy-...@googlegroups.com

I don’t know what the difference is between a Windows Spec file and a Liniux spec file.  I’m sure the differences are minimal.  I would look at the pyinstaller docs.

Elias Coutinho

unread,
Apr 21, 2021, 12:54:51 PM4/21/21
to kivy-...@googlegroups.com
On my Ubuntu 20.04 I created a .py file and tried to package using pyinstaller.

a = "It worked"
print (a)

He created it but when I went to the distance and ran the operating system he returned the following message:


There is no application installed for shared library files. Do you want to search for an application to open this file?

I believe that my operating system must be missing some lib.

Elliot Garbus

unread,
Apr 21, 2021, 12:58:07 PM4/21/21
to kivy-...@googlegroups.com

Start with a minimal kivy program.  The look at the log that gets created in the .kivy directory.  There are usually good hints on what is missing. 

Elias Coutinho

unread,
Apr 21, 2021, 1:02:15 PM4/21/21
to kivy-...@googlegroups.com
Note that in the previous message I am only using a print, nothing more, that is the problem or pyinstaller or my Ubuntu.

Elias Coutinho

unread,
Apr 21, 2021, 2:13:45 PM4/21/21
to kivy-...@googlegroups.com
It looks like he gave a more friendly feedback, now he misses the main.kv file

Below is the return of the project execution:

[INFO   ] [GL          ] Texture max size <16384>
[INFO   ] [GL          ] Texture max units <32>
[INFO   ] [Window      ] auto add sdl2 input provider
[INFO   ] [Window      ] virtual keyboard not allowed, single mode, not docked
[INFO   ] [GL          ] NPOT texture support is available
 Traceback (most recent call last):
   File "main.py", line 40, in <module>
   File "kivy/app.py", line 949, in run
   File "kivy/app.py", line 919, in _run_prepare
   File "main.py", line 36, in build
   File "kivy/lang/builder.py", line 304, in load_file

 FileNotFoundError: [Errno 2] No such file or directory: 'main.kv'
[36949] Failed to execute script main

Elias Coutinho

unread,
Apr 21, 2021, 4:29:34 PM4/21/21
to kivy-...@googlegroups.com
It's almost working!
How does your spec create a single file similar to --onfile?


Em ter., 20 de abr. de 2021 às 22:00, Elliot Garbus <elli...@cox.net> escreveu:

Elliot Garbus

unread,
Apr 21, 2021, 4:36:40 PM4/21/21
to kivy-...@googlegroups.com
With pyinstaller I always create a one directory build.  On Windows I use another app that creates a Windows Installer. 

On the Mac the directory is the “app”. On some projects I will compress it to post, for other I use a utility to create a .dmg file for distribution. 

I don’t know what the options are for Linux. 

Sent from my iPhone

On Apr 21, 2021, at 1:29 PM, Elias Coutinho <coutinh...@gmail.com> wrote:



Elias Coutinho

unread,
Apr 21, 2021, 4:59:51 PM4/21/21
to kivy-...@googlegroups.com
I achieved!

I pasted the spec inside the folder where the kv and py files are.
Notice the red lines:

# -*- mode: python ; coding: utf-8 -*-


block_cipher = None


a = Analysis(['main.py'],
             pathex=['/home/elias/Área de Trabalho/pasta'],
             binaries=[],
             datas=[('main.kv', '.'),],
             hiddenimports=[],

             hookspath=[],
             runtime_hooks=[],
             excludes=[],
             win_no_prefer_redirects=False,
             win_private_assemblies=False,
             cipher=block_cipher,
             noarchive=False)
pyz = PYZ(a.pure, a.zipped_data,
             cipher=block_cipher)
exe = EXE(pyz,
          a.scripts,
          a.binaries,
          a.zipfiles,
          a.datas,
          [],
          name='meu_app',
          debug=False,
          bootloader_ignore_signals=False,
          strip=False,
          upx=True,
          upx_exclude=[],
          runtime_tmpdir=None,
          console=True )


Now I have to solve the final problem.

The application only opens if it is through the terminal using ./my_app

I would like linux to run with just 2 clicks.


Elliot Garbus

unread,
Apr 21, 2021, 5:46:09 PM4/21/21
to kivy-...@googlegroups.com
Congratulations! Good luck getting those last issues solved.   

Sent from my iPhone

On Apr 21, 2021, at 2:00 PM, Elias Coutinho <coutinh...@gmail.com> wrote:


Reply all
Reply to author
Forward
0 new messages