stan-dev / pystan2

PyStan, the Python interface to Stan
GNU General Public License v3.0
920 stars 189 forks source link

Running PySTAN on Windows 10 from RStudio #743

Closed Emnlv closed 3 years ago

Emnlv commented 3 years ago

Hello,

I am having many problems in importing Pystan 2.19 in Windows 10 from RStudio 4.0.3, using Python version 3.7.9.

The output of my code is:

import pystan ImportError: DLL load failed: The specified module could not be found

What I have done: I ran Windows 7 procedure as described here: https://pystan.readthedocs.io/en/latest/windows.html It doesn't work

I tried the normal py -m pip install from the command It doesn't work

I tried to install RStudio from Anaconda, getting the Stan_environment, but the Pyhton script is not available.

I would like to change the Environment of my Rstudio (that one in the Desktop) to get that one of stan_env, but I am finding difficulties.

Do you know how to resolve this problem? And I would/want to continue to use it from RStudio.

Thank you in advance.

ahartikainen commented 3 years ago

On Windows you need to use conda workflow.

In RStudio, is there a way to select what python is used?

Here are some instructions how to get conda environments working with R.

https://stackoverflow.com/questions/58923166/installing-r-studio-with-anaconda

After you get this working, you can go forward and install pystan

e.g. conda install pystan -c conda-forge

Emnlv commented 3 years ago

Thank you: I have tried, but It doesn't work...

In RStudio, is there a way to select what python is used? -> unfortunately I am not understanding how to change it, because I would like to create the environment, download Pystan with conda and all the requirements and then connected to my RStudio, in order to try to use it.

ahartikainen commented 3 years ago

You probably first need to get conda and pystan working.

After that you probably need to start RStudio from cmd so that the stan_env has been activated.

Emnlv commented 3 years ago

At the end I had to use Spyder. Anyway, thank you for your support 👍