Skip to content

Extended CE: Python Runner

yu-i-i edited this page Sep 27, 2026 · 1 revision

Python Script Runner

The Python Script Runner lets you write and run Python scripts directly in your Overleaf project. Any files your script generates — figures, CSVs, or other outputs — are saved to the file tree and are available to use in your LaTeX document.


Python Script Runner

Activate the Python Script Runner

To use the Python Script Runner, open any .py file from your project's file tree. The editor switches to Python mode and a Run button appears.

If your project doesn't have a .py file yet, create one using the New file button in the file tree.

Write and run a script

  1. Open a .py file from the file tree.
  2. Write your Python code in the editor.
  3. Select Run to execute the script.

To stop a script while it's running, select Stop.

Understand the output panel

When you run a script, the output panel opens below the editor. It shows:

  • Standard output: text printed by your script, such as the result of print() statements

  • Errors: if your script fails, the output panel shows what went wrong. There are two types:

    • Environment errors: for example, a package that isn't available in the runner. Check the list of supported packages before importing.
    • Code errors: syntax mistakes or runtime errors in your script, such as a NameError or TypeError

Use files from the file tree as inputs

Your script can read files already in your project — for example, a .csv you've uploaded:

import csv
with open("data.csv") as f:
   reader = csv.reader(f)
   for row in reader:
     print(row)

Save output files to the file tree

Any files your script writes are saved to the project file tree automatically. For example, a figure saved with plt.savefig("output.png") will appear in the file tree and can be included in your LaTeX document using \includegraphics{output.png}.

Supported packages and Python version

The Python Script Runner uses Pyodide 0.29.3, which runs Python 3.13.2. A full list of supported packages is available on the Pyodide packages page.

Known limitations

  • Scripts run in your browser using your local system resources. Large or computationally expensive scripts may be slow or cause the tab to become unresponsive.
  • Only packages available in Pyodide are supported. Packages that require native code or are not in the Pyodide distribution cannot be installed.

Clone this wiki locally