Issue with running python script from a dotnet application


#1

We have a dotnet application which calls a simple python hello word program inside it :

The snapcraft.yaml is as below

    name: processorsnap
    version: '0.1'
    summary: A simple example snap for dotnet in snaps
    description: A simple example snap for dotnet in snaps

    grade: devel 
    confinement: strict 

    base: core

    apps:
      processorsnap:
        command: IoT_AnalyticsProcessor.Service
        daemon: simple
        plugs:
        - network-bind
        - network

    parts:
      processorsnap:
        source: .
        plugin: dump
        stage-packages:
            - libasn1-8-heimdal
            - libcurl3
            - libgssapi3-heimdal
            - libhcrypto4-heimdal
            - libheimbase1-heimdal
            - libheimntlm0-heimdal
            - libhx509-5-heimdal
            - libkrb5-26-heimdal
            - libldap-2.4-2
            - liblttng-ust0
            - libroken18-heimdal
            - librtmp1
            - libsasl2-2
            - libunwind8
            - liburcu4
            - libwind0-heimdal
            - icu-devtools
            - wget
            - zlib1g
            - python

but when i snap it and run it i get the below error :

the actual output when i run normally without snapping is as below :

Am i missing something related to python here like plugin or stage or build packages ?


#2

There’s two things that could be going-on:

  1. Your dotnet code might not be able to find hello.py.
  2. Your hello.py is found but failing to execute.

For the first potential problem you need to find out where your app is looking for the hello.py and attempt to either put your hello.py there or amend the search to look in the location that the file actually exists.

For the second potential problem the likely reason is the #! line is pointing to the wrong python executable path, because the return code from the exec call is “file not found”.


#3

Thanks for your response.

In our dotnet code we have specified the python runtime location (where the python executable file is found) /usr/bin/python and also the path of the python file hello.py

i tried to reproduce the error before snapping by giving a wrong path(for python runtime) and i see that this error occurs only if the path of the python runtime location is wrong :

so once i snap it if this error is occurring, what would be the reason ?.. the snap is not able to load the python executable from /usr/bin/python ??

Is python runtime automatically fetched by adding any libraries or build packages in snapcraft.yaml file ??


#4

your dotnet app should invoke /usr/bin/env python instead … and your snap should contain the python executable (as well as all the python modules hello.py needs)