Pystan C++/MSVC compiler issues- cl.exe failed with exit status 2

Happy Halloween Weekend! Sorry that I have to reach out to ask for your expertise and your guidance regarding this issue I am facing with installing pystan and the C++ configuration. I have followed every single step in this website:PyStan on Windows — PyStan documentation and I am still not sure what steps I am missing. this is the error that I am seeing:

~\anaconda3\lib\distutils\ in compile(self, sources, output_dir, macros, include_dirs, debug, extra_preargs, extra_postargs, depends)
    424                 self.spawn(args)
    425             except DistutilsExecError as msg:
--> 426                 raise CompileError(msg)
    428         return objects

CompileError: command 'C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.33.31629\\bin\\HostX86\\x64\\cl.exe' failed with exit status 2

I just want to show here all the steps that I have taken and installed and honestly, I am not sure what steps that I am missing. Does this occur because of windows 11? or if any of the experts could help me understand what are the C++ configuration and requirement? I am trying my best to leave no stone unturned because I truly want to learn pystan.

Thank you for reading my post and helping with this.

1.Create pystan in conda environment:

Requirement already satisfied: pystan in c:\users\lanng\anaconda3\lib\site-packages ( Requirement already satisfied: Cython!=0.25.1,>=0.22 in c:\users\lanng\anaconda3\lib\site-packages (from pystan) (0.29.15) Requirement already satisfied: numpy>=1.7 in c:\users\lanng\anaconda3\lib\site-packages (from pystan) (1.18.1)

2.mingw-w64 installation checked

c++ (Rev4, Built by MSYS2 project) 12.2.0 Copyright (C) 2022 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  1. msvc:
Microsoft (R) C/C++ Optimizing Compiler Version 19.33.31630 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

usage: cl [ option... ] filename... [ /link linkoption... ]

Appreciate your suggestion and your time very much. I am open to any suggestion and ideas to resolve this issue and finally be able to get pystan running.

You need to use older python (e.g. 3.8).

Have you considered using CmdStanPy or maybe setup wsl with ubuntu 22 and then use the latest pystan?

Hi Ari,
Appreciate your suggestion, Yes I am using python 3.7.9 and I am able to create the stan environment in conda. When you mentioned the latest version of pystan, are you referring to this version:PyStan — pystan 3.5.0 documentation? (v3.5.0). In the installation doc, I still need to satisfy the requirement for C++ compiler. I just want to see whether you can help direct on the right steps to get C++ compile correctly and whether you could have any insights about this. Do you think the reason that I am seeing this issue is because I am using windows 11?
Thank you so much for your kindness and patience. I appreciate it very much. I will try to look into using cmdstanpy.