> ## Documentation Index
> Fetch the complete documentation index at: https://docs.riza.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Python

> Execute Python in a secure and isolated runtime environment

<Note>
  This page is about the Python interpreter
  environment inside the Riza Code Interpreter API.
  If you're looking to call the API from Python,
  head over to the [API Client Libraries](/getting-started/client-libraries) page.
</Note>

The environment your Python runs in depends on the [underlying Riza
environment](/interpreters/introduction) associated with your
runtime.

By default Python runs in our highly-performant WASI environment. If you're
executing Python in a [custom runtime](/getting-started/adding-packages), then your
Python runs in our microVM environment.

## Runtime

Riza runs [Python 3.12.0](https://www.python.org/downloads/release/python-3120/)
compiled to WASM (in the default WASI environment) or directly (in the microVM environment).
The entire standard library is included.

To add additional packages from PyPI, you'll need to build a custom runtime. See
[Adding Packages](/getting-started/adding-packages) for more information.

## Resource limits

There are no limitations beyond the general [limits](/reference/limits)
that apply to all Riza interpreter runtime environments.

See our [roadmap](/reference/roadmap) for planned future improvements.

## Standard I/O

You can write to `stdout` and `stderr` as you typically would.

```python theme={null}
import sys

print('Hello, World!')
print('Something bad happened', file=sys.stderr)
```

You can read from `stdin` and access command line arguments and environment
variables, all as you typically would.

```python theme={null}
import os, sys

print(sys.stdin.read())
print(sys.argv)
print(dict(os.environ))
```

## Files

<Note>
  The filesystem is read-only in all environments.
</Note>

You can pass input files via the API using the `files` parameter in the WASI and V8 environments.
This feature is not yet available in the microVM environment.

See the [Files reference](/reference/files) for more details.

## Accessing the network

<Note>
  Network access is blocked by default, so you need to allow traffic to
  individual hosts using the `http` request parameter. See the [HTTP](/reference/http)
  reference for a full example.
</Note>

### In the WASI environment

You can make HTTP requests using the `requests` or `httpx` packages. Protocols other
than HTTP are not supported, and code can't access the network directly.

```python theme={null}
import requests

resp = requests.post("https://httpbin.org/post", json={
    "foo": "bar",
})
print(resp.json())
```

### In the microVM environment

You can access the network any way you like, but you'll need to set the (unfortunately
named in this context) `http` request parameter to allow traffic to all hosts. Host-specific
network controls are not yet supported.

```json theme={null}
"http": {"allow": [{"host": "*"}]}
```
