RuntimeError: Exception: Don't do this


#1

Operating System: Windows 10
Python Version: 3.6.1
Interface Version: 2.16.0.0
Compiler/Toolkit: MinGW

Dear All,

I have encountered a very mysterious runtime error trying to compile a simple model. My code is the following:

…SOME FUNCTION

fits = []

for i, model_code in enumerate(model_codes):

sm = StanModel_cache(model_code=model_code)

fits.append(sm.sampling(data=data,chains=2))

return fits

Where StanModel_cache is the example cache function from the docs. The error is not related to the pickling, since I tried to compile a model normally and still ended up the getting this:

multiprocessing.pool.RemoteTraceback: **
"""
Traceback (most recent call last):
** File “C:\Users\Lenovo 500\AppData\Local\Programs\Python\Python36\lib\multiprocessing\pool.py”, line 119, in worker

** result = (True, func(args, kwds))
** File “C:\Users\Lenovo 500\AppData\Local\Programs\Python\Python36\lib\multiprocessing\pool.py”, line 44, in mapstar
*
** return list(map(args))*
** File “stanfit4anon_model_6fabfab1b05cee6c931433fbe37f8071_5647248379771553170.pyx”, line 368, in stanfit4anon_model_6fabfab1b05cee6c931433fbe37f8071_5647248379771553170._call_sampler_star (C:\Users\LENOVO~1\AppData\Local\Temp\tmp670pr_y1\stanfit4anon_model_6fabfab1b05cee6c931433fbe37f8071_5647248379771553170.cpp:8334)**
** File “stanfit4anon_model_6fabfab1b05cee6c931433fbe37f8071_5647248379771553170.pyx”, line 401, in stanfit4anon_model_6fabfab1b05cee6c931433fbe37f8071_5647248379771553170._call_sampler (C:\Users\LENOVO~1\AppData\Local\Temp\tmp670pr_y1\stanfit4anon_model_6fabfab1b05cee6c931433fbe37f8071_5647248379771553170.cpp:8986)**
RuntimeError: Exception: Don’t do this (in ‘unkown file name’ at line 23)

“”"

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
** File “C:/Users/Lenovo 500/Desktop/Projects/Machine Learning with Python/supervised_learning.py”, line 116, in **
** fit = sample(model_codes, data)**
** File “C:/Users/Lenovo 500/Desktop/Projects/Machine Learning with Python/supervised_learning.py”, line 95, in sample**
** fits.append(sm.sampling(data=data,chains=2))**
** File “C:\Users\Lenovo 500\AppData\Local\Programs\Python\Python36\lib\site-packages\pystan\model.py”, line 725, in sampling**
** ret_and_samples = _map_parallel(call_sampler_star, call_sampler_args, n_jobs)**
** File “C:\Users\Lenovo 500\AppData\Local\Programs\Python\Python36\lib\site-packages\pystan\model.py”, line 81, in _map_parallel**
** map_result = pool.map(function, args)**
** File “C:\Users\Lenovo 500\AppData\Local\Programs\Python\Python36\lib\multiprocessing\pool.py”, line 260, in map**
** return self._map_async(func, iterable, mapstar, chunksize).get()**
** File “C:\Users\Lenovo 500\AppData\Local\Programs\Python\Python36\lib\multiprocessing\pool.py”, line 608, in get**
** raise self._value**
RuntimeError: Exception: Don’t do this (in ‘unkown file name’ at line 23)

Any help would be very appreciated.

Thank You in advance!

Stefan


#2

Hi,

On Windows, if you use official CPython (>3.5) , you can not compile models with MinGW compiler, because it is incompatible with Python. You have to use Visual Studio C++ compiler (MSVC 14.0 / 2015 or newer, actually PyStan is not currently working with 14.1/ 2017 due to distutils being incompatible with it.).

https://wiki.python.org/moin/WindowsCompilers

Here is one option to solve the problem:

What I have done on Windows, is that I have started to use docker container (debian/ubuntu) with PyStan and needed libraries installed on there and then use Jupyter Notebook with mounted local folder.

And here is a second one (I do not recommend this):

Use a CPython distribution compiled with MinGW. Somewhere in the conda space there is an implemented distribution.


#3

Hey ahartikainen,

thanks for your quick reply! That explains it. I moved my project to my linux environment (long live gcc) and everything works like a charm now.

Best,
Stefan