#Running python working only in dev

7 messages · Page 1 of 1 (latest)

warm oyster
#

I use python scripts to generate some data and pass it to typescript with shell api via command.spawn

const command = new Command("run-python", [
    path,
    String(x0),
    String(x1),
    String(a),
    String(E),
    String(V0),
    String(m),
    String(diracConstant.Js),
  ])

This works only in dev mode. In production I get some problems with python environment(pic) .I don't use any venv. I thought tauri would handle system commands the same way in dev and production. It seems like a python issue but I can't figure out why this problem doesn't occur in dev mode then.

Shell api is enabled in tauri.conf.json of course

"allowlist": {
      "all": false,
      "shell": {
        "all": false,
        "execute": true,
        "open": true,
        "scope": [
          {
            "name": "run-python",
            "cmd": "python3",
            "args": true
          }
        ]
      }

Python scripts are added as resource and fs api is enabled

"fs": {
        "all": true,
        "scope": ["$RESOURCE/python/*"]
},
"bundle": {
      "active": true,
      "resources": ["python/*"],

I can get scripts paths without a problem in both dev and production using resolveResource

const path = await resolveResource("python/potential_barrier.py")

and overall I don't get any errors related to incorrect path or resource not available.

I would appreciate any help with that problem

warm oyster
#

This issue does not happen on windows 10 but on kubuntu 23.10

warm oyster
#

It turns out this problem only happens with AppImage. After installing .deb everything works

broken moth
#

Do you think you can create a minimal reproduction repo for us to try?

It wouldn't be the first problem with appimages by far but it's not exactly the same issues that have open issues on github already 🤔

warm oyster
#

Sure can do

#

The problem can be seen even without running python file. In example I used python -c print('Hello world!') like so:

import { Command } from "@tauri-apps/api/shell"

async function runCommand() {
  const cmd = new Command("run-python", ["-c", "print('Hello World!')"])

  cmd.stdout.on("data", (text) => console.log(`No error output: ${text}`))
  cmd.stderr.on("data", (text) => console.log(`Error output: ${text}`))

  await cmd.spawn()
}