Skip to main content

How do I use Code Interpreter to run Python code in le Chat?

Updated yesterday

The Code Interpreter lets you run Python inside le Chat to explore data, make charts, and automate small tasks, all without leaving the conversation.

Itโ€™s great for quick analyses and โ€œshow meโ€ moments during a chat.

What you can do

  • Quick math and ad-hoc scripts

  • Data analysis from CSV, XLSX, JSON

  • Charts and visuals for trends and comparisons

  • Scientific computing and small simulations

๐Ÿ“Œ In le Chat Free, usage is rate-limited. For heavier workloads, upgrade to le Chat Pro.

Activate the Code Interpreter

Code Interpreter is off by default.

Turn it on in the Tools menu (1) and then select Code Interpreter (2).

image

Click Tools (1) and then Code Interpreter (2)

Run your first snippet

Ask le Chat to write Python for your task and it will run the code for you.

Example:

Load this CSV and show the top 5 rows, then plot sales by month.

When code appears, it runs in a secure sandbox and returns tables, figures, or files as needed.

image

le Chat running Python code in the sandbox

๐Ÿ”‘ The sandbox has no internet access. If your data is at a URL, download it locally and upload the file before running code.

Work with files

You can upload CSV, XLSX, JSON, images, and more using the + button.

Typical prompts:

  • Summarize this spreadsheet and flag outliers.

  • Clean this CSV, fix missing values, and export a new file.

  • Extract all emails from this PDF and give me a CSV.

๐Ÿ”Ž New to file uploads? See Upload and analyze your files for a quick walkthrough.

Make charts

Ask for visuals and the interpreter will render them inline.

# Line chart
df.set_index("date")["sessions"].plot()
# Bar chart by category
df.groupby("region")["revenue"].sum().plot(kind="bar")
# Save a chart to download
import matplotlib.pyplot as plt
plt.savefig("revenue_by_region.png")

image

A chart generated by the Code Interpreter

Environment details and limits

  • Code runs in a temporary, sandboxed environment.

  • No internet access from Python.

  • Uploaded files are available for the current session.

  • Common libraries are preinstalled (for example, pandas, numpy, matplotlib). If something is missing, ask le Chat for an alternative.

๐Ÿšจ Donโ€™t paste secrets. Never share API keys or credentials in chat or code.

Tips

  • Be specific about columns, filters, and output format.

  • Ask for explanations (for example, Explain the steps and show the code).

  • Iterate (for example, Looks good. Now add a rolling average and label the axes).

  • If you hit a limit, upload a smaller sample to prototype, then scale up.

๐Ÿ”‘ The Code Interpreter is perfect for analysis-in-chat. For larger projects, use a local IDE and bring results back to the conversation.

Next steps

Want to turn outputs into a document you can iterate on and share?

๐Ÿง‘โ€๐Ÿ’ผ Iโ€™m a user and I want to create and share interactive documents with Canvas

Did this answer your question?