CmdStanPy in RStudio

Hi all,

This is related to query I posted in the slack help channel:

I receive the attached error message when attempting to sample from a CmdStan model within a Python file in RStudio. I do not see this error message when I run the same file outside of RStudio even when using the same Python interpreter with the same cmd_stan_path.

Based on the suggestion of @ahartikainen, I checked the temp folder in the error message for any .txt error files, but could not find any.

It would be good to hear from anyone who has successfully used CmdStanPy within RStudio, and of course it would be great to hear your suggestions in general.

Thanks as always,

1 Like

I would check then just cmdstan using bash, etc. (to find out if the error is really Rstudio-specific)

Put this on top the python code

from functools import partial
import subprocess
subprocess.Popen = partial(subprocess.Popen, stdin=subprocess.DEVNULL)

Why this is needed: No idea


Thanks to everyone who engaged with this. The code proposed by @ahartikainen has solved the problem for me!

1 Like