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

# Python Execution

> Run Python code and Jupyter notebooks on Lyceum Cloud from VS Code or the CLI

## Video Tutorial

<div className="flex justify-center">
  <video controls className="w-full rounded-lg" src="https://mintcdn.com/lyceum/qko2EiFIg1Uy6ET0/videos/python-cli-execution.mp4?fit=max&auto=format&n=qko2EiFIg1Uy6ET0&q=85&s=bc408298c0cdd36e9de570da9a948d4b" data-path="videos/python-cli-execution.mp4">
    Your browser does not support the video tag.
  </video>
</div>

## VS Code Extension

The recommended way to run Python on Lyceum Cloud.

### Installation

1. Open VS Code
2. Go to Extensions (`Ctrl+Shift+X`)
3. Search for "Lyceum Cloud"
4. Click Install

<div className="flex justify-center">
  <img src="https://mintcdn.com/lyceum/qRgkOPfw7UJyLSZk/images/install.png?fit=max&auto=format&n=qRgkOPfw7UJyLSZk&q=85&s=5f2900ed587926bb2fe286bf2b224117" alt="Install Lyceum Cloud Extension" height="500" width="1000" data-path="images/install.png" />
</div>

### Authentication

1. Open any `.py` or `.ipynb` file
2. Click the cloud icon in the editor toolbar
3. Authenticate in your browser
4. Return to VS Code, you're ready

<Note>
  Authentication tokens are securely stored and automatically refreshed.
</Note>

### Running Code

<Tabs>
  <Tab title="Python Files" icon="python">
    **Toolbar Button**, Click the cloud icon in the editor toolbar

    **Keyboard Shortcut**, `Ctrl+Shift+E` (`Cmd+Shift+E` on Mac)

    **Command Palette**, `Ctrl+Shift+P` → "Execute on Cloud"

    <div className="flex justify-center">
      <img src="https://mintcdn.com/lyceum/qRgkOPfw7UJyLSZk/images/execution.png?fit=max&auto=format&n=qRgkOPfw7UJyLSZk&q=85&s=4bebf4bc678665b9c680f47e46366ceb" alt="Execute Python Code" height="500" width="1000" data-path="images/execution.png" />
    </div>
  </Tab>

  <Tab title="Jupyter Notebooks" icon="book">
    **Cell Execution**

    * Open a Jupyter notebook
    * Click "Execute on Cloud" on any code cell
    * View real-time output as it streams from the cloud

    **Kernel State**

    * The extension keeps track of previous executions
    * Variables are synced between local and remote environments

    <Note>Notebook outputs, including visualizations and data frames, are displayed in VS Code just like local execution.</Note>
  </Tab>
</Tabs>

### File Operations

<AccordionGroup>
  <Accordion icon="upload" title="Upload Files to Cloud">
    Right-click files or folders in the VS Code Explorer → "Upload to Lyceum Cloud".
  </Accordion>

  <Accordion icon="folder" title="Manage Cloud Files">
    View, download, and delete files in the "Lyceum Cloud Files" panel.
  </Accordion>
</AccordionGroup>

### Commands Reference

| Command                | Shortcut       | Description                                |
| ---------------------- | -------------- | ------------------------------------------ |
| Execute on Cloud       | `Ctrl+Shift+E` | Run current Python file or notebook cell   |
| Upload to Lyceum Cloud | `Ctrl+Shift+U` | Upload selected files                      |
| Manage Executions      | `Ctrl+Shift+M` | Open execution management panel            |
| Configure API Token    | —              | Set authentication token (manual override) |
| View Execution History | —              | Show execution history                     |

## CLI

### Installation

```bash theme={null}
pip install lyceum-cli
```

### Authentication

```bash theme={null}
lyceum auth login
```

This opens a browser for OAuth-style authentication. For headless environments, use `lyceum auth login --manual --api-key <KEY>`.

Check status at any time:

```bash theme={null}
lyceum auth status
```

### Running Code

```bash theme={null}
# Run inline code
lyceum python run "print('Hello from Lyceum Cloud!')"

# Run a file
lyceum python run hello.py

# Run with a specific machine type (defaults to cpu)
lyceum python run train.py -m gpu.a100

# Run with requirements
lyceum python run script.py -r requirements.txt

# Pre-import modules (can be repeated)
lyceum python run script.py --import numpy --import pandas

# Pass script arguments after --
lyceum python run train.py -- --epochs 10 --batch-size 32
```

See [Machine Types](/docs/configuration/machine-types) for the available `-m` values.

### Workspace Configuration

If a `.lyceum/config.json` file exists in your project, the CLI will automatically pick up dependencies and other settings from it.

```bash theme={null}
# Initialize config in the current workspace
lyceum python config init

# View current config
lyceum python config show
```

To skip the workspace config for a single run, pass `--no-config`.

## Troubleshooting

<AccordionGroup>
  <Accordion icon="key" title="Authentication issues">
    * Re-authenticate by clicking the cloud icon in VS Code or running `lyceum auth login`
    * Check that you're signed in to the [dashboard](https://dashboard.lyceum.technology)
    * Verify internet connectivity and firewall settings
  </Accordion>

  <Accordion icon="folder-open" title="File operation issues">
    * Verify network connectivity during upload
    * Ensure you are authenticated
    * For very large files, contact support
  </Accordion>
</AccordionGroup>

<Note>
  Need help? Contact [support@lyceum.technology](mailto:support@lyceum.technology).
</Note>
