3

I've installed pystan and am trying to verify that the installation has worked correctly.

When I go to the IPython console in Spyder and run the following code line by line, it generates the correct answer.

import pystan

model_code = 'parameters {real y;} model {y ~ normal(0,1);}'
model = pystan.StanModel(model_code=model_code)
y = model.sampling().extract()['y']
y.mean()

The line calling pystan.StanModel takes about 30 seconds, while the other lines execute instantaneously. In the end I get the right result (about 0, e.g. 0.01 or -0.01).

However, when I run the code as a single script in Spyder, it doesn't work, and instead the console just runs forever, doesn't produce a result, and I have to manually shut down Anaconda. Why is that?

  • (*Spyder maintainer here*) You probably need to add `pystan` to `Tools > Preferences > Python Interpreter > User Module Reloader > Set UMR excluded (not reloaded) modules`. Please let me know if that works so we can exclude it by default. – Carlos Cordoba Nov 12 '18 at 23:17
  • Unfortunately that didn't work. I added pystan, then restarted Anaconda and Spyder and checked that it was still added to UMR excluded. As before, the code works if executed line by line but when I run all the code as a single script nothing happens (aside from a lot of CPU noise) and I need to restart the kernel. – user1205901 - Слава Україні Nov 13 '18 at 12:13

1 Answers1

2
  1. Run Spyder as administrator
  2. Check your antivirus to make sure whether it is blocking your code
  3. Reset Spyder:

spyder --reset

spyder --defaults

holegar
  • 36
  • 6
  • 2
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jul 20 '22 at 08:59