How to create a reprex containing Python code from R/RStudio?

I have Python installed and working in RStudio thanks to reticulate.

For teaching, it would be very useful to create reprexes of Python code from inside the RStudio IDE but I cannot get it working. I've tried the reprexpy package but cannot install it for some reason. I've also tried starting with reticulate::repl_python() - long shot - and with py_run_file() but that shows no output.

Here's an Rmd file showing some simple Python code that I'd like to reprex:

---
title: "Untitled"
author: "Robin Lovelace"
date: "06/02/2021"
output: html_document
---

```{r}
# Fails:
# reticulate::py_install("reprexpy")

import matplotlib.pyplot as plt
import numpy as np

fig, ax = plt.subplots()  # Create a figure containing a single axes.
ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the axes.

Good news, the following reprex worked, but does not show any output:

reticulate::py_run_file("/tmp/test-matlip.py")

Created on 2021-02-06 by the reprex package (v1.0.0)