Hi - I’m trying to use the most recent version of cmdstanpy and it won’t import - the error message I get is
File "/users/mattb242/sharedscratch/sigdet_clean/lib/python3.13/site-packages/stanio/csv.py", line 42
while (file_header := fd.readline()).startswith("#"):
^
SyntaxError: invalid syntax
This is somewhat baffling, since the version of stanio is the one installed by cmdstanpy itself, as is the version of Python (3.13.0), which should accept this syntax. If I kludge a fix by changing the code so that it doesn’t use the walrus operator it manages to get through importing stanio and then falls over importing numpy with the following
Hi Brian - I’m running it from a Python script on an HPC cluster. At the moment I’ve just reduced it to one thread, however, to isolate the various problems I’ve been having with parallelisation - one of which could have been solved by uninstalling and reinstalling cmdstanpy in a clean environment, which I did - at which point the above started to happen.
I suspect your environment may be somehow messed up such that you are not using the version of Python you think you are. Depending on how your HPC works, one option could be doing module loads and environment activations in the wrong order
Before you import cmdstanpy could you import sys and print(sys.version)?
I have installed a new clean environment, put Python 3.10 in it and set my PYTHONPATH to that. import sys and print(sys.version) confirms that I am using the right version. My batch script loads up some modules (conda, mpi, gcc, all in the right versions) and then activates the module.
That’s very mysterious, then. The file paths you put in the original post look like they’re for a python 3.13 installation, what version are you hoping to use?
After much wrangling I have solved the issue by uninstalling and reinstalling cmdstanpy in an entirely clean environment, purging some cached files in .conda/packages, pointing the CMDSTAN variable to the cmdstanpy installation, installing mpi4py with pip rather than conda and using a different mpi module that was available on the cluster. Thanks.