PyStan works in Google colab

I just tested and PyStan works in Google Colab, which allows running Python notebooks in your browser. This can be useful for demoing or when giving a course and someone has problems with C++ installation in their laptop.

PyStan is not installed by default, but running

!pip install pystan

works, and models compile successfully (maybe slower than in modern laptop, but not too bad).

You can open notebooks also directly from github. In addition of the notebook you need upload Stan model files and possible utility functions (like Mike’s diagnostic utilities) , but again for demos and courses this works quite easily.


It also works with google drive so one can keep models and files in there.

I wonder if it can compile pystan from source (2.18+).

If one is going to do case studies so that the idea is to run them on colab, then one could precompile + pickle + compress + “filename with platform and version info” + small function to load the models or recompile them … just saying.

1 Like

How about a case study for this?

1 Like


here is one rough example.

Can someone test if it works. Also it would be nice to have some example that has running time of days?

When ArviZ goes to pypi we can use it for plotting.

1 Like

Any idea why pystan stop working in Google colab!

!pip install pystan
import pystan

return: No module named ‘pystan’

The importable name for pystan is stan, so !pip install pystan then import stan works for me

It was working before. See Google Colab

This may have changed when PyStan moved from version 2 to 3