Brief Review of PyScript on WordPress

Anaconda has introduced PyScript at PyCon US 2022. It enables client-side execution of Python codes in web browsers, and they say it is already compatible with Numpy, Pandas, and other third-party modules. I gave it a quick try on WordPress.


  • WordPress 5.9.3
  • Lightning 14.20.3
  • Safari 15.4 or Google Chrome 101.0.4951.54
  • MacOS 12.3.1
  • Apple M1 Pro


The custom HTML block seems to be the best place for PyScript codes. Some simplest codes work there.

<link rel="stylesheet" href="" />
<script defer src=""></script>
print("Hello, world!")


print("Hello, world!")

Here comes the greeting! However, PysScript looks to override the default CSS settings, and the bold headings on this page are no longer bold. Similarly, bullet points of a list are missing.

Whether they are spaces or tabs, indents raise IndentationError (as of May 5, 2022).

for i in range(5):


for i in range(5): print(i)

Numpy works, at least very partly.

<py-script output="mpl">
import numpy as np
print(f"π = {np.pi}")
<div id="mpl"></div>


import numpy as np print(f'π = {np.pi}')

Matplotlib fails.

- matplotlib
<py-script output="mpl2">
from matplotlib import pyplot as plt
import numpy as np
x = np.linspace(0, 2 * np.pi)
y = np.sin(x)
fig, ax = plt.subplots()
ax.plot(x, y)
<div id="mpl2"></div>


- matplotlib from matplotlib import pyplot as plt import numpy as np x=np.linspace(0,2*np.pi) y=np.sin(x) fig,ax=plt.subplots() ax.plot(x,y)

I find PyScript incredibly exciting and promising. WordPress may need some updates to get along with it better.

One thought on “Brief Review of PyScript on WordPress

Leave a Reply

Your email address will not be published. Required fields are marked *