Python support is experimental. This quickstart runs a program using the bundled standard library, then tests it with unittest. No third-party packages are needed.
No CPython install
Elide runs Python 3.13 and its standard library itself.
Install
Install Elide using a method that supports Python, then add the Python component if it is not already included:
elide setup python
elide info
elide info should list python on its Languages: line. If the shell cannot find elide, follow
Verify the install. If Python support is missing, see
Python is not installed.
elide setup python --channel=release or --channel=nightly picks the channel; --force reinstalls the component.
Run Python
Create a directory for this example:
mkdir hello-python
cd hello-python
Save this as greeting.py:
import json
def greeting(name: str) -> str:
return f"Hello, {name}!"
if __name__ == "__main__":
print(json.dumps({"message": greeting("Ada")}))
elide python greeting.py
{"message": "Hello, Ada!"}
The json import uses the standard library included with the Python component.
Tests
Create test_greeting.py in the same directory:
import unittest
from greeting import greeting
class GreetingTest(unittest.TestCase):
def test_names_the_caller(self):
self.assertEqual(greeting("Ada"), "Hello, Ada!")
Run unittest as a module:
elide python -m unittest -v test_greeting
The runner should report one test and OK. If it cannot import greeting or test_greeting, check the filenames
and run the command from hello-python.
elide test does not discover Python tests. For discovery across several files or pytest, see
Python tests.
Next steps
- Add packages: install dependencies with the optional Python package tooling, or use a compatible external virtual environment.
- Run a project entry point: use the scripts in
pyproject.toml. - Call JavaScript from Python: share values between languages.
- Check compatibility before moving an existing application.
Command-line arguments
elide python takes Python interpreter arguments before the script or module. For an existing app.py:
elide python app.py --name Elide --count 2 # sys.argv: ['app.py', '--name', 'Elide', '--count', '2']
elide python -c 'import sys; print(sys.version)'
elide python -m json.tool input.json
echo 'print("from stdin")' | elide python -
Tokens after the script, -c CMD, or -m MODULE go to the program. Bare elide python starts the REPL in a
terminal and reads standard input otherwise.
~/demo bat hello.py
───────┬────────────────────────────────────────────────────────────────────────────────────────────
│ File: hello.py
│ Size: 95 B
───────┼────────────────────────────────────────────────────────────────────────────────────────────
1 │ import json
2 │ import sys
3 │
4 │ print(json.dumps({"name": sys.argv[1], "runtime": "Elide"}, indent=2))
───────┴────────────────────────────────────────────────────────────────────────────────────────────
~/demo elide python hello.py Ada
{
"name": "Ada",
"runtime": "Elide"
}
The general commands run .py files with the same sys.argv:
elide app.py
elide run app.py
elide -l python -s 'print(1 + 1)'
Interpreter options
Put these before the script, -c, or -m. elide --help-all lists them under “Python interpreter options”.
| Flag | Effect |
|---|---|
-c CMD | Run CMD as the program; trailing tokens become sys.argv[1:]. |
-m MODULE | Run a library module as __main__. |
-s | Don’t add the user site directory to sys.path. |
-I | Isolated mode. |
-E | Ignore PYTHON* environment variables. |
-S | Don’t import site on startup. |
-P | Don’t prepend a potentially unsafe path to sys.path. |
-B | Don’t write bytecode files. |
-u | Unbuffered standard output and error. |
-O | Optimization level; repeat for -OO. |
-b | Warn on bytes/str comparisons; repeat to raise errors. |
-W ARG | Warning control; repeatable. |
-x | Accepted for compatibility; no effect. |
Two flags are on by default: -S, because Elide builds sys.path itself and skips site for startup time, and
-B. sys.flags reports both. To import site (.pth files, sitecustomize), pass
-X polyglot.python.NoSiteFlag=false; to write bytecode, pass -X polyglot.python.DontWriteBytecodeFlag=false.
Standard library
The standard library includes json, pathlib, sqlite3, ssl, zlib, and ctypes. bz2 and lzma need no
system libbz2 or liblzma. For the database drivers Elide includes, see Databases.
JavaScript interop
With --interop, Python evaluates JavaScript through the built-in elide module:
# sum.py
from elide import js
print(js("[1, 2, 3].reduce((a, b) => a + b, 0)"))
elide --interop python sum.py
JavaScript and TypeScript import a Python module’s default export:
// main.mjs
import mod from "./mod.py";
console.log(mod.hello());
elide --interop run main.mjs
Without --interop, these calls fail. See Languages and Interop.
Third-party packages
Package installation requires pytools, the optional package tooling installed with the Python component. Use
elide uv install PACKAGE, or elide install --ecosystems=pypi for declared dependencies. Plain elide install
retains its Maven default.
Packages installed through Elide use the project’s automatic environment. A compatible Python 3.13 external
virtual environment can also supply packages through VIRTUAL_ENV.
Only compatible wheels can be installed; source builds and arbitrary CPython native wheels are not supported. See Packages and virtual environments for setup, commands and limitations.
Tracing and metrics
The opentelemetry API and logging export traces, metrics, and logs through Elide, with no SDK installed; see
OpenTelemetry in Python.
Known limitations
- C extensions: some C extension modules do not load.
- macOS: native module isolation is not available.
- WebAssembly SIMD: installing Python disables it; see WebAssembly with Elide.
- CPython differences: some edge cases behave differently from CPython 3.13; see the Compatibility Matrix.