Ask / Submit

How to run a Python app?

asked 2016-06-12 11:26:55 +0300

Ósanwe gravatar image


I've cloned a sample python project and tried to build and run it. But sailfish-qml doesn't exist and I can't run the sample.

Previously I installed pyotherside-qml-plugin-python3-qt5 manually:

[root@Jolla nemo]# pkcon install pyotherside-qml-plugin-python3-qt5
Waiting in queue                                                               
Refreshing software list                                                       
Resolving dependencies                                                         
Installing packages                                                            
Waiting in queue                                                               
Waiting for authentication                                                     
Waiting in queue                                                               
Refreshing software list                                                       
Resolving dependencies                                                         
Installing packages                                                            
Downloading packages                                                           
Installing packages

Also I tried to run sample via terminal:

[root@Jolla nemo]# sailfish-qml pythonsample
bash: sailfish-qml: command not found

and install sailfish-qml

[root@Jolla nemo]# pkcon install sailfish-qml
Command failed: This tool could not find any available package: could not find sailfish-qml

How to build and run python apps correct?

Thanks in advance!

edit retag flag offensive close delete

1 Answer

Sort by » oldest newest most voted

answered 2016-06-12 11:39:25 +0300

updated 2016-06-12 11:44:47 +0300

The example project does not work correctly, I found the way to use pyotherside in Sailfish QML. This took me several days until I fully understand why...

Warning: only Python 3 is supported! I never found a way to get my code running on Python 2...

First in your QML you import this:

import io.thp.pyotherside 1.3

They use 1.4 but that's not allowed in Harbour!

Then you can add the 'Python {}' to your QML:

    id: python

        // Import the pad where you Python file is stored. In this case: /qml/pages

        // Import the module, the name = name of your Python script.
        importModule('pythonModule', function () {});

        // Receive here data from Python by using: pyotherside.send('receiver', data)
        setHandler('receiver', function(data) {
            // Do some stuff here with the data and QML.

        // when an exception is raised, this error handler will be called
        console.log('python error: ' + traceback);

        // All the stuff you send, not assigned to a 'setHandler', will be shown here:
        console.log('got message from python: ' + data);

If you want to use pyotherside in your project make sure you add it to your .yaml file as a dependency under 'Requires':

- sailfishsilica-qt5 >= 0.10.9 
- pyotherside-qml-plugin-python3-qt5 >= 1.3.0

I never run it from the terminal, I deploy it with the SDK as an RPM package. In this case your app shows up as a normal app in the app grid and is started automatically after deploying.

edit flag offensive delete publish link more


Thanks! I edited the project but the problem is same. I found that libsailfishapp-launcher should be in Requires section. I added this line and received follow error: Error: File './oss/armv7hl/libsailfishapp-launcher-1.0.10-10.7.1.jolla.armv7hl.rpm' not found on medium ''. When I tried to install this package via pkcon manually I got the same error.

Ósanwe ( 2016-06-12 12:05:47 +0300 )edit

I never had that error before, Sailfinder (in the Jolla Store) uses heavily Python and I only added one line to Requires.

Dylan Van Assche ( 2016-06-12 12:11:17 +0300 )edit

do pkcon refresh before manipulating with repos

coderus ( 2016-06-12 12:26:09 +0300 )edit

@coderus: It helped. Thanks!

Ósanwe ( 2016-06-12 12:34:07 +0300 )edit
Login/Signup to Answer

Question tools



Asked: 2016-06-12 11:26:55 +0300

Seen: 939 times

Last updated: Jun 12 '16