[PYTHON] Install PyStan on Windows without Anaconda

If you want to run PyStan on Windows, it's easiest to use Anaconda, and the official documentation also describes how to install using Anaconda. PyStan on Windows — PyStan documentation

If you don't use Anaconda, your next option would be to consider running PyStan on a Linux virtual environment, such as with WSL 2.

But that's not even possible, ** what if you want to run PyStan on Windows that doesn't have access to Anaconda or Linux virtual environments **?

environment

I tried it on Windows Server 2019 built on Amazon EC2, but it should be about the same on Windows 10. (suitable)

It doesn't seem to matter much, but I use PowerShell to execute commands.

Install python

First, install Python.

This time I installed Python 3.8.6. I will omit it because I just download the installer normally and click it.

Python Release Python 3.8.6 | Python.org

Install the C ++ compiler

PyStan uses the C ++ compiler at runtime and must be installed.

According to the official document, "MSVC compiler is not supported.", But when I tried it with MinGW-w64, it didn't work ... [^ mingw-w64] And it worked fine for Microsoft Visual C ++, which seems to be unsupported, so this time I will write about this method.

[^ mingw-w64]: I installed MinGW-w64 and set the build-time compiler = mingw32 option in distutils.cfg through the path, but what else did I need?

Download and run the "Build Tools for Visual Studio 2019" installer from the download page. (In the lower menu) Download Visual Studio 2019 for Windows & Mac

When the installer starts, check "C ++ Build Tool" and install it.

Install Cython and NumPy

Install Cython and NumPy in advance, as you will need them when installing PyStan.

$ pip install cython numpy

Install PyStan

The latest version as of November 2020 is 2.19, but it didn't work, so I'll include 2.17. [^ pystan2.19]

[^ pystan2.19]: If pystan == 2.19, the installation will end immediately, but when importing, an error such as "Import Error: DLL load failed while importing _api" will appear and it cannot be used. It looks like the build isn't running during installation, but I don't know the details.

$ pip install pystan==2.17.1.0

Operation check

Let's run a simple sample code.

from pystan import StanModel

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

Success if a 0-like value is displayed without any error.

end

Windows I don't know anything.

And who is in demand for this article? ?? ??

Recommended Posts

Install PyStan on Windows without Anaconda
Anaconda on Windows Terminal
Install pygraphviz on Windows 10
[Python] How to install OpenCV on Anaconda [Windows]
How to install / verify graphviz on anaconda / windows10
Install Numpy on virtualenv on Windows
Install watchdog on Windows + Python 3.3
Install Win-Kex (kali-linux) on Windows 10.
Install module on Anaconda (Mac)
Install Chainer 1.6 (GPU) on Windows 7.
Notes on installing Anaconda 3 on Windows
[Python] [Chainer] [Windows] Install Chainer on Windows
Install anaconda on Mac → Add Library
Pip install --ugrade pip fails on Windows
Anaconda python environment construction on Windows 10
Install python2.7 on windows 32bit environment
Install xgboost (python version) on Windows
Install Python on Windows + pip + virtualenv
Build and install OpenCV on Windows
Install Pytorch on Blender 2.90 python on Windows
How to install pycrypto on Windows
Use Tensorflow 2.1.0 with Anaconda on Windows 10!
Install Python development environment on Windows 10
How to install music 21 on windows
Install easy_install and pip on windows
# Solution when pip install gives an error when using Anaconda on Windows 10
Install opencv on Mac using Anaconda Navigator
Install scipy on Linux without internet connection
[Kivy] How to install Kivy on Windows [Python]
Install wsl2 and master linux on windows
Use without installing python 2.x on Windows
How to install richzhang / colorization on Windows 10
Run py.test on Windows Anaconda and MinGW
Personal Note Package to install on Anaconda
Python on Windows
Install easy_install (Windows)
Theano on Anaconda
Install and run Python3.5 + NumPy + SciPy on Windows 10
Install Python3, numpy, pandas, matplotlib, etc. on Windows
How to quickly install h5py on Windows 10 [Unofficial]
Eliminates SSL error when PIP Install on Windows.
Install ZIP version Python and pip on Windows 10
Install mecab on Marvericks
Install Tensorflow on Mac
Install TensorFlow on Ubuntu
Install python on WSL
Install Faiss on CentOS 7
Install pyenv on mac
Run Kali Linux on Windows with GUI (without VirtualBox)
Install Python on Pidora.
Install mongodb on termux
Install Scrapy on python3
Pylint on Windows Atom
Install docker on Fedora31
Linux (WSL) on Windows
Install numba on CentOS 7.2
[Node] [npm] Install npm packeage on MacOS / Linux without sudo
Install Ansible on Mac
Install Python on Mac
Install Python 3 on Mac
Create a comfortable Python 3 (Anaconda) development environment on windows