PyStan and PyCharm

Hello all,

I have recently trying to use PyStan in Windows and found out it’s installation is more difficult than I thought. I normally use PyCharm as my IDE and was hopping to use PyStan with it. However, most advice I saw on the internet suggested I installed Anaconda instead, which I believe it comes with it’s onw IDE.
My question is: is it worth to learn how to work with Jupiter or Spider just for the sake of using PyStan? Should I try to find a way to incorporate both PyCharm and PyStan? Or should I try to call RStan (via subprocess for example) from python instead?

Thanks in advance!

1 Like

PyStan needs mingw-w64 compiler and this is usually done with conda package manager which also install needed changes for python distutils.

You could link your PyCharm to conda env, but the problem is, that it is currently a bit broken, because user needs to call activation script to enable mingw.

See discussion in https://github.com/stan-dev/pystan/issues/520

Ps. I personally recommend jupyter lab as an IDE

1 Like

Alright, I installed Anaconda and following the windows instructions on the PyStan documentation to Windows and I managed to run PyStan in a conda environment.

I’m still trying to work around the problems surrounding PyCharm and PyStan as I’d really like to use PyCharm. However, I’m already trying out Juptyer Lab, thank you for the recommendation.

Thank you for your response!

Hi @DjentMachine Did you resolve the issue? Are you able to use pystan on pycharm?

Hi @bgoodri,

Will I be able to install pystan on pycharm at present without any issues?

hi Murali,

you could also try using CmdStanPy instead of PyStan - it has fewer package dependencies.
https://cmdstanpy.readthedocs.io/en/latest/

Hi @mitzimorris thanks. this works on pycharm as well? I’m so much used to the IDE, so asking

maybe I should try installing pystan first?

does the PyCharm IDE let you install packages from PyPi?
if so, install package cmdstanpy.
in the IDE, you should be able to install CmdStan on your machine via the install_cmdstan().

I haven’t used PyCharm, so I’d be interested to know if this works.

1 Like

PyStan and CmdStanPy need to run in different virtual environments, and CmdStanPy requires Python3.

Pystan requires conda virtual environment right? I have been configuring that as of now

Hi, see this issue

You need to make sure to activate your conda or adding special folders to PATH

2 Likes

Hi @ahartikainen I am following that link.

Btw, regarding the the C++ compiler; do I have to install again for MacOS? I have installed it recently while installing rStan

Probably not.

1 Like

Thanks. Yes, it did not ask me to install again

I just installed pystan. Actually it was straightforward. I used pip to install and I don’t think I used coda even though I configured the condo environment.

The 8 school example runs perfectly on pystan. This means stan is working properly?

I’m not sure if mingw-w64 was installed using Conda. but pystan is installed now and the 8schools examples is running successfully. This means mingw-w64 got installed?

On windows try

gcc --version
which gcc

Im on macOS Catalina. How do I check?

mingw is a Windows only thing. With a good compiler on macOS you don’t need conda. So everything looks good. (You can insert those to terminal)

Apple clang version 11.0.3 (clang-11##.0.32.29)
Target: x86_64-apple-darwin19.2.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
/usr/bin/gcc

This is what I got

Looks good.

1 Like