Anaconda prompt closed suddenly after installing PyMc3 and warning in importing pymc3

Hello everyone,
I have two questions related the issues I am facing. I am new on PyMc3 and still struggling to work in flow. The issues are following:

  1. When I installed PyMc3 using the command: conda install -c conda-forge pymc3. The anaconda prompt crashes and now I am not able to open it. When I click on it to open, it pop up and closes immediately.
  2. ‘import pymc3’ leads to the following message:
    WARNING (theano.tensor.blas): Using NumPy C-API based implementation for BLAS functions.

Very strange. I don’t know what this could mean. Maybe rebooting can solve the problem, but not being able to open the Command Prompt cannot be a python error.

Can you import theano in python? This should raise the warning you are seeing. If you want to install theano with mkl services and not use the slower NumPy C-API, you should follow their instructions first:

conda install numpy scipy mkl-service libpython m2w64-toolchain
conda install theano pygpu
conda install -c conda-forge pymc3

Thank You very much for your reply!Rebooting didn’t help but apparently deleting the file ‘vs2015_compiler_vars.bat’ from the computer helped and anaconda prompt is working now.
However, [regarding 2nd] you are right. I followed your instructions and now there is no error while importing the theano and pymc3 as well. Thank you!

but I am getting following error when I run the code, the line when sample the variable raise error:

[These two line raise the error:]

with basic_model:
trace=pm.sample(5000)

OUTPUT:

runfile(‘F:/Dropbox/Catania/Python_codes/dummy_codes/test_tensorVariable.py’, wdir=‘F:/Dropbox/Catania/Python_codes/dummy_codes’)
Auto-assigning NUTS sampler…
Initializing NUTS using jitter+adapt_diag…
Multiprocess sampling (4 chains in 4 jobs)
NUTS: [sigma, Azim]
Traceback (most recent call last):

File “”, line 1, in
runfile(‘F:/Dropbox/Catania/Python_codes/dummy_codes/test_tensorVariable.py’, wdir=‘F:/Dropbox/Catania/Python_codes/dummy_codes’)

File “C:\Users\singh.CT\AppData\Local\Continuum\anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py”, line 786, in runfile
execfile(filename, namespace)

File “C:\Users\singh.CT\AppData\Local\Continuum\anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py”, line 110, in execfile
exec(compile(f.read(), filename, ‘exec’), namespace)

File “F:/Dropbox/Catania/Python_codes/dummy_codes/test_tensorVariable.py”, line 45, in
trace=pm.sample(5000)

File “C:\Users\singh.CT\AppData\Local\Continuum\anaconda3\lib\site-packages\pymc3\sampling.py”, line 439, in sample
trace = _mp_sample(**sample_args)

File “C:\Users\singh.CT\AppData\Local\Continuum\anaconda3\lib\site-packages\pymc3\sampling.py”, line 986, in _mp_sample
chain, progressbar)

File “C:\Users\singh.CT\AppData\Local\Continuum\anaconda3\lib\site-packages\pymc3\parallel_sampling.py”, line 313, in init
for chain, seed, start in zip(range(chains), seeds, start_points)

File “C:\Users\singh.CT\AppData\Local\Continuum\anaconda3\lib\site-packages\pymc3\parallel_sampling.py”, line 313, in
for chain, seed, start in zip(range(chains), seeds, start_points)

File “C:\Users\singh.CT\AppData\Local\Continuum\anaconda3\lib\site-packages\pymc3\parallel_sampling.py”, line 204, in init
self._process.start()

File “C:\Users\singh.CT\AppData\Local\Continuum\anaconda3\lib\multiprocessing\process.py”, line 112, in start
self._popen = self._Popen(self)

File “C:\Users\singh.CT\AppData\Local\Continuum\anaconda3\lib\multiprocessing\context.py”, line 223, in _Popen
return _default_context.get_context().Process._Popen(process_obj)

File “C:\Users\singh.CT\AppData\Local\Continuum\anaconda3\lib\multiprocessing\context.py”, line 322, in _Popen
return Popen(process_obj)

File “C:\Users\singh.CT\AppData\Local\Continuum\anaconda3\lib\multiprocessing\popen_spawn_win32.py”, line 65, in init
reduction.dump(process_obj, to_child)

File “C:\Users\singh.CT\AppData\Local\Continuum\anaconda3\lib\multiprocessing\reduction.py”, line 60, in dump
ForkingPickler(file, protocol).dump(obj)

BrokenPipeError: [Errno 32] Broken pipe

Could you run your script as a batch script instead of a spyder dedicated terminal? That way, you will see the actual exception that is causing the BrokenPipeError. The most likely candidate is that you did not enclose the pm.sample inside an if __name__ == "__main__": statement.

Try rerunning with

if __name__ == "__main__":
    with basic_model:
        trace=pm.sample(5000)

I added the line as you suggested and run the script in cmd, got same error:

F:\work\Python_codes\dummy_codes>python test_tensorVariable.py
Auto-assigning NUTS sampler…
Initializing NUTS using jitter+adapt_diag…
Multiprocess sampling (4 chains in 4 jobs)
NUTS: [sigma, Azim]
Traceback (most recent call last):
File “”, line 1, in
File “C:\Users\singh.CT\AppData\Local\Continuum\anaconda3\lib\multiprocessing\spawn.py”, line 105, in spawn_main
exitcode = _main(fd)
File “C:\Users\singh.CT\AppData\Local\Continuum\anaconda3\lib\multiprocessing\spawn.py”, line 114, in _main
prepare(preparation_data)
File “C:\Users\singh.CT\AppData\Local\Continuum\anaconda3\lib\multiprocessing\spawn.py”, line 225, in prepare
_fixup_main_from_path(data[‘init_main_from_path’])Traceback (most recent call last):

File “test_tensorVariable.py”, line 45, in
File “C:\Users\singh.CT\AppData\Local\Continuum\anaconda3\lib\multiprocessing\spawn.py”, line 277, in _fixup_main_from_path
trace=pm.sample(5000)
File “C:\Users\singh.CT\AppData\Local\Continuum\anaconda3\lib\site-packages\pymc3\sampling.py”, line 439, in sample
run_name=“mp_main”)
File “C:\Users\singh.CT\AppData\Local\Continuum\anaconda3\lib\runpy.py”, line 263, in run_path
trace = _mp_sample(**sample_args)
File “C:\Users\singh.CT\AppData\Local\Continuum\anaconda3\lib\site-packages\pymc3\sampling.py”, line 986, in _mp_sample
pkg_name=pkg_name, script_name=fname)
File “C:\Users\singh.CT\AppData\Local\Continuum\anaconda3\lib\runpy.py”, line 96, in _run_module_code
chain, progressbar)mod_name, mod_spec, pkg_name, script_name)

File “C:\Users\singh.CT\AppData\Local\Continuum\anaconda3\lib\site-packages\pymc3\parallel_sampling.py”, line 313, in init
File “C:\Users\singh.CT\AppData\Local\Continuum\anaconda3\lib\runpy.py”, line 85, in _run_code
for chain, seed, start in zip(range(chains), seeds, start_points)exec(code, run_globals)

File “C:\Users\singh.CT\AppData\Local\Continuum\anaconda3\lib\site-packages\pymc3\parallel_sampling.py”, line 313, in
File “F:\Dropbox\Catania\Python_codes\dummy_codes\test_tensorVariable.py”, line 49, in
for chain, seed, start in zip(range(chains), seeds, start_points)pm.traceplot(trace);

File “C:\Users\singh.CT\AppData\Local\Continuum\anaconda3\lib\site-packages\pymc3\parallel_sampling.py”, line 204, in init
NameError : self._process.start()name ‘trace’ is not defined

File “C:\Users\singh.CT\AppData\Local\Continuum\anaconda3\lib\multiprocessing\process.py”, line 112, in start
self._popen = self._Popen(self)
File “C:\Users\singh.CT\AppData\Local\Continuum\anaconda3\lib\multiprocessing\context.py”, line 223, in _Popen
return _default_context.get_context().Process._Popen(process_obj)
File “C:\Users\singh.CT\AppData\Local\Continuum\anaconda3\lib\multiprocessing\context.py”, line 322, in _Popen
return Popen(process_obj)
File “C:\Users\singh.CT\AppData\Local\Continuum\anaconda3\lib\multiprocessing\popen_spawn_win32.py”, line 65, in init
reduction.dump(process_obj, to_child)
File “C:\Users\singh.CT\AppData\Local\Continuum\anaconda3\lib\multiprocessing\reduction.py”, line 60, in dump
ForkingPickler(file, protocol).dump(obj)
BrokenPipeError: [Errno 32] Broken pipe

Ok, now you see the error that causes the broken pipe:

Okay. Can You please suggest me how can I correct it? or suggest me earlier discussion/example, from where I can learn about it. I am very very new with python as well as on PyMc3
Thank You!

I think that the best starting point is to run sample with the option cores=1, that should make the errors source clearer.

The error seems to indicate that at some point in your code you try to use a variable called trace before it was given a value. A good reference about this error can be found here

Thank You very much for your help! Indeed cores=1 raised no error.

Thanks Again!

I’m glad that solved your problem! I’m sorry for the short replies before, I was in a bit of a hurry and couldn’t really explain why you got the broken pipe error. If you want to read through the link I posted in my earlier reply, you’ll see that this is a common problem for our windows users. There are also some tips on how to deal with the problem, and still be able to sample chains in parallel.

I’m glad it’s working, but it’s pretty restrictive to only be able to use a single core. What version of Windows are you using?

If you have a professional or educational version, you should be able to use Docker, or alternatively it should have a Linux kernel you can use. I eventually gave up on installing Theano on Windows directly, but it works smoothly in a Docker.

It may also help to put it in an anaconda environment so that you can erase it and start over if something goes wrong. Installing things in the wrong order can break your installation, which means that if you later install a package that pins a dependency at another version than you started with, and it uninstalls and re-installs, say, numpy, then you’ll get errors again. It may be easiest to start the environment over. This is easy in an environment, and a pain outside of one.

2 Likes

Thank You very much for your suggestions. I am using windows 10. I will try to switch on Linux based OS soon. Thanks again!

Not all versions of windows 10 are the same. Do you know if you’re using Home, Professional, or Education? If the latter two, you should already have a linux environment within Windows.

Sorry for late reply. Its Windows 10 Enterprise. Thanks

I’m pretty sure enterprise should work.

You can follow the instructions here to get the Linux subsystem, then install anaconda, add it to path like you would on a Linux system, then follow the installation instructions from before. My order of operations is usually cython, numpy theano, pymc3.
If you use jupyter you may have to use an ssh connection to connect your Linux subsystem to a browser. I usually use docker so I always use ssh to connect a port, but you should also be able to use docker on Enterprise so that’s another option. Also, the subsystem’s file system is also something that you can access through windows explorer but it’s hard to find.

Thank you so much for your kind reply! I am surely going to do it.

import pymc3
WARNING (theano.tensor.blas): Using NumPy C-API based implementation for BLAS functions.
Traceback (most recent call last):
File “”, line 1, in
File “C:\Users\Beach.LAPTOP-UIO549S1\anaconda3\lib\site-packages\pymc3_init_.py”, line 13, in
from .stats import *
File “C:\Users\Beach.LAPTOP-UIO549S1\anaconda3\lib\site-packages\pymc3\stats_init_.py”, line 32, in
geweke = map_args(az.geweke)
AttributeError: module ‘arviz’ has no attribute ‘geweke’