Skip to content

Pythonista

Pythonista is a Python development environment for iOS. Protocol Launcher allows you to generate deep links to open Pythonista, edit or run scripts, pass command-line arguments, select the Python interpreter version, and execute embedded code.

Usage

There are two ways to use this library:

  • On-Demand import from subpaths enables tree-shaking and keeps bundles small.
  • Full Import from the root package is convenient but includes all app modules.

Pick On-Demand for production builds; Full Import is fine for quick scripts or demos.

Select Installation Method

On-Demand
Recommended. Optimized for production.
Full Import
Convenient. Good for quick scripts.

Open App

On-Demand
ts
import { open } from 'protocol-launcher/pythonista'

const url = open()

Open Pythonista 3

On-Demand
ts
import { open } from 'protocol-launcher/pythonista'

const url = open({
  scheme: 'pythonista3',
})

Open Pythonista 2

On-Demand
ts
import { open } from 'protocol-launcher/pythonista'

const url = open({
  scheme: 'pythonista2',
})

Open Script

On-Demand
ts
import { openScript } from 'protocol-launcher/pythonista'

const url = openScript({
  path: 'MyScript.py',
})

Open iCloud Script

On-Demand
ts
import { openScript } from 'protocol-launcher/pythonista'

const url = openScript({
  path: 'MyScript.py',
  root: 'icloud',
})

Open iCloud Script by Path

On-Demand
ts
import { openScript } from 'protocol-launcher/pythonista'

const url = openScript({
  path: 'iCloud/MyScript.py',
})

Run Script

On-Demand
ts
import { runScript } from 'protocol-launcher/pythonista'

const url = runScript({
  path: 'MyScript.py',
})

Run iCloud Script

On-Demand
ts
import { runScript } from 'protocol-launcher/pythonista'

const url = runScript({
  path: 'MyScript.py',
  root: 'icloud',
})

Run Script with args

On-Demand
ts
import { runScript } from 'protocol-launcher/pythonista'

const url = runScript({
  path: 'MyScript',
  args: 'foo bar',
})

Run Script with argv

On-Demand
ts
import { runScript } from 'protocol-launcher/pythonista'

const url = runScript({
  path: 'MyScript',
  argv: ['foo', 'bar'],
})

Run Script with version

On-Demand
ts
import { runScript } from 'protocol-launcher/pythonista'

const url = runScript({
  path: 'MyScript.py',
  version: 3,
})

Run Script with py

On-Demand
ts
import { runScript } from 'protocol-launcher/pythonista'

const url = runScript({
  path: 'MyScript.py',
  py: 3,
})

Execute Code

On-Demand
ts
import { exec } from 'protocol-launcher/pythonista'

const url = exec({
  code: 'print("Hello from Pythonista")',
})